You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The biggest problem with a Map is, that the field names get sorted alphabetically. This shouldn't be a big problem for the deserialization of the generated Json object, but you can't enforce the order of your object fields. So in the above example, "firstName" becomes the first field.
Drawback of a list is, that you could provide by accident a second field name with the exact same name (in a map, the last one wins), but as the writer of the serializer you are responsible for a correct serialization of your object anyways.
The text was updated successfully, but these errors were encountered:
toburger
changed the title
Object serialization: do not use a Map<string, Json>
Object deserialization: do not use a Map<string, Json>Sep 8, 2017
toburger
changed the title
Object deserialization: do not use a Map<string, Json>
Object serialization: do not use a Map<string, Json>Sep 8, 2017
I would suggest to use a
list<string, Json>
instead of aMap<string, Json>
.The usage is simpler by not having to use
Map.ofList
:The biggest problem with a
Map
is, that the field names get sorted alphabetically. This shouldn't be a big problem for the deserialization of the generated Json object, but you can't enforce the order of your object fields. So in the above example, "firstName" becomes the first field.Drawback of a list is, that you could provide by accident a second field name with the exact same name (in a map, the last one wins), but as the writer of the serializer you are responsible for a correct serialization of your object anyways.
The text was updated successfully, but these errors were encountered: