I'm deserializing a JSON document to a Map using the generics
support. I'd like any nested JSON objects in the document to also be
deserialized to a Map, creating a Map of Maps.
The trouble is that the parser balks on not having type information
for nested objects, and I'm not sure how to supply it:
Map doc = gson.fromJson("{"foo": {"bar": 1}}",
new TypeToken<Map<String, Object>>(){}.getType());
java.lang.RuntimeException: com.google.gson.JsonParseException: Type
information is unavailable, and the target object is not a primitive:
{"bar": 1}
Thanks for any advice, and for creating Gson!
Cheers,
- Daniel
I have a similar question, I need to get a Map from a generic JSON
Object, I thought using the JsonObject would help.
All I need is to convert something like;
{value1 : "value 1", value2 : ["1", "2"] }
to a Map is it possible? Without knowing the bean type I want to map
it to?
Thanks,
Arun Shanker Prasad.
On Jan 19, 7:32 am, Daniel Carleton <daniel.carle...@exaptic.com>
wrote: