Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4870

I'm a bit confused about serializers

$
0
0

@Abuelo wrote:

I have a data source that returns JSON in something of a mix between what the documentation describes as the JSONSerializer and JSONAPISerializer.

The return has a root attribute but no type information:

{"data":[
	{"id":1,"name":"Blue"},
	{"id":4,"name":"Red"},
	{"id":5,"name":"Green"},
	{"id":3,"name":"Yellow"},
	{"id":2,"name":"Purple"}
	]
}

This obviously produces a problem with either of the serializers because it has a root (which the same across all models - it is always data) but no type information. The root causes it to error for the other serializer because it doesn’t expect one to be there.

Changing the data source isn’t really an option for me but the only way I can see forward is having to make a custom serializer for each model in the application to account for the root and lack of type. I really don’t want to do that!

Any advice appreciated

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4870

Trending Articles