0

I've following as a String in Java. How to get only {"FirstName":"Deepak","LastName":"Kabra"} value from below String using Java or Jackson? Please help

{"map_":{"FirstName":"Deepak","LastName":"Kabra"}}"
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

1 Answers1

0

I recommend utilizing Jackson's TreeModel. If you use it and get the String into a JsonNode, then you can just use

jsonNode.get("map_")

and you'll have the string you want.

Edited with code example:

String jsonString = "{"map_":{"FirstName":"Deepak","LastName":"Kabra"}}";

ObjectMapper mapper = new ObjectMapper();
JsonNode obj = mapper.readTree(jsonString);
JsonNode desiredString = actualObj.get("map_");
8bytewonder
  • 9
  • 1
  • 3