Closed yohanmishkin closed 8 years ago
Looking at the spec, it looks like your JSON should look like this:
{
"data": {
"attributes": {
"name": null,
"price": 12
},
"relationships": {
"review": null
},
"type": "book"
}
}
Note that instead of the data
key being null
, the review
key itself is null
.
That said, if this JSON was generated by e.g. Ember Data, my reading of the spec might be wrong. In that case, this is a bug and should be fixed. I'm also not sure that Saule does the right thing even with this change.
Yeah, it's not immediately clear how to interpret the spec, but the JSON was generated by Ember Data.
I'm pretty pragmatic about the spec in this.. if Emer Data generates this then Saule probably needs to support it. I'd appreciate a PR fixing this issue, which is probably caused by something we're doing in the ResourceDeserializer.
Sounds good. I'll give it a shot and circle back.
I published a new pre-release with the fix (thanks to @goo32).
Saule is fantastic! Thanks a million for all the work. Quick question:
My application is posting the following json to a Saule resource with a relationship and the deserializer is unable to deserialize the review object because its data is null. Any thoughts
The BookResource look like this:
I receive an "Object reference not set to an instance of an object." error during deserialization of the book's review.
Is there a simple way to override the deserializer to a null check perhaps or am I maybe doing something blatantly wrong?