Re: Partial JSON deserialization

Andy Guibert
 

A JsonbAdapter can go between Map<String, ?> and the java type it's an adapter for.  In the `adaptFromJson(Map<String,?>)` method you can handle polymorphism yourself if needed.  We do this in one of our test cases for OpenLiberty for example:
https://github.com/OpenLiberty/open-liberty/blob/master/dev/com.ibm.ws.jsonb_fat/test-applications/jsonbapp/src/web/jsonbtest/LocationAdapter.java

In this test we have a Location interface with Pod and ReserveableRoom being two concrete implementations.  The adapter is capable fo detecting which type to convert to by inspecting the incoming map.  So I was envisioning you could check the type attribute in your adapter and use that information to determine which concrete class it maps to.

Join jsonb-spec@javaee.groups.io to automatically receive all group messages.