Use Serializers to Access Legacy APIs

As much as we might hope to leave them behind, sometimes we need to work with a legacy API. We don’t have to throw out our entire model layer, though. By making use of JSONAPISerializer, we can take the raw data returned by this API and get it into the form we expect.

With Ember Data, a serializer is a class that takes a block of data and translates it into a different form for storage in an external context. For example, a serializer can be used to modify attribute names to match your expected format. You can take a raw JSON payload and alter its structure to match your model layer or remove extraneous information. And you can serialize your model data back into the format the server expects and save ...

Get Deliver Audacious Web Apps with Ember 2 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.