0

i want to parse this code to get the id's location in an array.

Json is as follows:

"tipSecurableSet": {
            "id": "082bdd09-6cff-41f9-a6f6-16a5bcc2eaa6",
            "items": [
              {
                "typeId": "c5831702-15ed-483d-8253-c890e3f97dae",
                "ids": [
                  "44b3efd4-5f7f-4698-aba4-1f4d9605c4eb"
                ],
                "id": "b838aa0d-522a-411e-958a-41c711c6a856"
              },
              {
                "typeId": "01c3c7de-2856-4665-90bc-a614caf335cd",
                "ids": [
                  "8240a190-7e14-4ba4-87be-22febd09fa69"
                ],
                "id": "62e62bf5-7a18-4518-a917-bb908d61fdd2"
              }
            ]
          }
        }
yash
  • 2,101
  • 2
  • 23
  • 32

1 Answers1

1

You should take a look at Org.JSON library.

You can get the IDs very easily once you have your JSONObject. There are many ways to construct a JSONObject. You can parse XML.toJSONObject or use one of the JSONObject constructors.

JSONObject obj= new JSONObject(...);
Iterator<String> keys= obj.keys(); //Gets your Fields or Keys

To get the object for a key, here is an example with a String and an Array of JSONObjects.

String id= jsonArray.getJSONObject(i).getString("typeID")
CoupFlu
  • 311
  • 4
  • 20