0

I have a JSON string that looks like:

"{\"info\":{\"length\":{\"value\":18},\"name\":{\"value\":\"ABC\"}}}"

say, length and name are attribute names

I have another map (say attributeMap) that (created from the results I retrieve from the database) map has attribute name and attribute value association stored. I need to be able to parse the string and compare the value an attribute has in the above string with the value returned from the attributeMap. Based on those comparisons, I will need to take some decisions.

In order to do this, I should convert the above string to a format that would help make the above comparison easier and efficient. I don't think I should be writing my own parser to do this. what would a right way to do this?

user1892775
  • 2,001
  • 6
  • 37
  • 58

1 Answers1

0

You should use any JSON Parser, like GSON (Google) (Recommended for simplicity), JACKSON, the simple org.json, or any other..

Then you will get a JSONObject/JSONNode to navigate and do the comparison.

You can find a parsing example here: How to parse JSON in Java

Community
  • 1
  • 1