I'm assuming you're using symbols to keep the data private, but this means you're going to have to go through some extra steps if you want that data included in the JSON representation.
Here's an example using toJSON
on your model to explicitly export the properties you care about
export class PostEdit {
// ...
toJSON() {
return {
postID: this.postID,
title: this.title,
text: this.text
};
}
}
Or
export class PostEdit {
// ...
toJSON() {
let {postID, title, text} = this;
return {postID, title, text};
}
}
When JSON.stringify
is called on your instance, it will automatically call toJSON
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…