Data serialization

If you walk through the npm repository, you might see a lot of packages that do data serialization. This section uses a library called js2xmlparser to show you various possibilities, such as providing a way to encode data—not only as JSON, but also as XML.

Remember that you can decide what flavor of framework you want to use.

To keep enriching our order-api application, imagine that you have a new request to provide support for XML encoding of request and response bodies as well. You may not want to duplicate the routes and controller; first, because it is not the best solution, and second, because you don't want to. One of the easiest ways to implement it is by using external packages such as js2xmlparser, as we mentioned ...

Get Hands-On RESTful Web Services with TypeScript 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.