-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serializing array issue #107
Comments
without a unique id there is no way to determine which items from the are variants suppose to be resource objects in your system? if so they should have an id, if not remove the id property and they will be treated as attributes |
Hi thanks, This happens during creation, so i POST those variants to the API and i don't have the |
From the specification (https://jsonapi.org/format/#document-resource-identifier-objects)
Root objects can get away without an Id (as described on https://jsonapi.org/format/#crud-creating) however linked objects have to exist to form a relationship I think the intended json:api way is two separate POST requests would be done to create the Although i'm aware that is probably not how your APIs were designed to handle it, giving the variants ids will allow the serializer to handle it so you can get it to the server I'm not sure how we could build support for this in the serializer as having multiple null ids does not make sense as we cant reference them. If you were to list all null ids in included, you would have no way to knowing which included item is referenced. For example if you had another field It could be argued that the serializer should throw an error in this case, we didn't go down that route as it is particularly difficult to track down errors when the particular value of a property causes the serializer to throw, and in most cases it was thought that it is better to not stop the entire response if only part of it is suspicious |
Hello,
I have this class VLRideDTO (simplified version here) with a property Variants that is a collection of VLVariantDTO:
When I serialize it using
JsonConvert.SerializeObject(data, new JsonApiSerializerSettings())
I notice that there is only one Variant under included:For debugging purpose, I am pasting the serialization result when I use just
JsonConvert.SerializeObject(data)
:As you can see, there's supposed to be two variants.
What am I doing wrong? How can I get both variants to end up in the json:api format?
Thanks!
The text was updated successfully, but these errors were encountered: