0

I'm trying for the first time to use the jsonsimple library on java. So i formatted a json object using a String. the Object is the following

{
   "mario":{
   "city": "rome",
   "birth": 1980,
  "haircolor": "blonde"
  },
"Lucas": {
  "city": "milan",
  "birth": 1985,
  "haircolor": "brown"
   }
}

From these object i need to get the names in a String format. Thanks everyone for any kinda of help.

Ryuzaki L
  • 37,302
  • 12
  • 68
  • 98

1 Answers1

0

JsonObject implements java.util.Map, so you can simply call the keySet-Method on your JsonObject.

Example:

JsonObject myJsonObject = ...;
Set<String> allNamesInThisObject = myJsonObject.keySet();
Felix
  • 2,256
  • 2
  • 15
  • 35