re: Serialization in Node REST APIs VIEW POST

FULL DISCUSSION
 

When it comes to serialising to JSON, I don't think there's a better option than JSON.stringify() in Node, which is what response.json() uses in express, by the way.

If you need to map database objects to response objects, you don't really need to pull in a library, you can just write a function to do any data transformation you need.

const mapPonyToResponse = (pony) =>
  ({
    name: pony.name,
    gender: pony.gender || 'female',
    type: types[pony.type].human_readable,
    // And so on.
  })
code of conduct - report abuse