-
Notifications
You must be signed in to change notification settings - Fork 109
Description
Hi,
I need to deserialize data from an external provider where I have no control of the format and one of the attributes can be an array or an object.
Sample data:
{"type":"snapshot","data": [{"name": "John"},{"name":"Jane"}]}and
{"type":"update","data": {"name": "John"}}I have tried creating a POJO class with constructors supporting both object and array format, i.e. Data and Data[]
I have tried creating variations using a mix of constructors and setters.
I started to look at mixins but I didn't get very far as documentation and sample code referring to mixins is minimal.
I have created many converters to serialize/deserialize many custom data types like timestamps for example. Would a custom converter or more specifically a custom JsonReader.ReadObject be required?
Is it supported using dsl_json in any way?
More generally, I have often wanted to optionally deserialize data based on the presence of an attribute and have never managed to figure out if it was possible.
As always, thanks for all your effort in a great library!