0

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, i.e. 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?

2
  • What is res.json? If you are in a node.js environment, you might want to tag your question with nodejs Commented Jan 22, 2014 at 18:52
  • this is express. response giving a JSON Commented Jan 22, 2014 at 19:01

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.