How to Parse JSON(with dynamic root element) response in JAVA

{
  "elastic": {
    "username": "elastic",
    "roles": [
      "superuser"
    ],
    "full_name": null,
    "email": null,
    "metadata": {
      "_reserved": true
    },
    "enabled": true
  },
  "kibana": {
    "username": "kibana",
    "roles": [
      "kibana_system"
    ],
    "full_name": null,
    "email": null,
    "metadata": {
      "_deprecated": true,
      "_deprecated_reason": "Please use the [kibana_system] user instead.",
      "_reserved": true
    },
    "enabled": true
  }
}
0 3 234
3 REPLIES 3

Not applicable

As per me the best use of JSON can be done using javascript.

I could suggest to try this.

Tell us more. What do you mean by "parse JSON"?

What are you really trying to do?

I want the username and roles of every element...

I got the answer by doing it with map as key value paires