-1

I am trying to parse JSON string using JSONParser class. Can anybody help figuring out how to get the tag name also. For example take this string:

{ people:{[ name: John, age: 27],[name: Alen, gender: female]}}

If I have an object containing name "John" and age "27", how can I get the tag names, like in this case are name and age?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
user3480127
  • 3
  • 1
  • 5

1 Answers1

0

You're probably using some existent library, I guess quick-json. In order to get a Map (that you can later iterate through map.entrySet()) you can do:

JSONParser parser=factory.newJsonParser();
Map map=parser.parseJson(jsonString);

Also take a look at this thread for more information on other libraries.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
mauriciojost
  • 370
  • 1
  • 11