I need to quickly parse out the root node of similar JSON like below:
[
{"key":"foo", "value":123},
{"key":"bar", "value":"Hello World!"},
{"key":"far", "value":{"something":1}}
]
Simply put, I need to look at the “key”‘s value (i.e. “foo”, “bar”, “far”), to determine if I need to fully deserialize the “value” portion to POJOs.
I have tried creating a class for POJO mapping, but that has a lot of overhead and it especially doesn’t like a Map because the inside of my value is sometimes a value-type and sometimes more JSON.
Any ideas how I can traverse the keys quickly and then take the value out and deserialize it?
Thanks in advance!
You might want to bind as a tree (ObjectMapper.readTree(), gives JsonNode of root node), traverse, and then deserialize values separately, using ObjectMapper.readValue(valueNode)?