Partial JSON deserialization

Richard Evans

I have a JSON object like:

{ "type": "sometypestring",
  ... other common attributes ...
   "data" : { an object defined by the type value }

I'd like to use Jsonb to deserialize the object, but leave the data value as raw JSON so I can examine the type and then use fromJson with the required Java class.  The attributes could be sent in any order, so I can't rely on reading the type first and then using the lower-level deserializaiton support.

Is there something like a @JsonRaw annotation which will leave part of the object unparsed?  I suspect I can define the data property in the Java class as a JsonStructure, but then how would I use Jsonb to deserialize this?  Without writing it back to a string and reading it again?



Join to automatically receive all group messages.