So I have a CustomObject and an array containing a number of them.
Right now, when I say res.json(myArray), I get a standard jsonification of my CustomObject, ie field1:value, field2:value, ....
What I can not figure out is how to make a custom jsonification of my CustomObject, such as I only want to return a subset of the parameters.
What functions do I have to customize? In CustomObject only?
What functions do I have to customize? In CustomObject only?
Give your objects a toJSON
method that returns an object with only the expected properties and it will be recognized by JSON.stringify
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.