0

I am trying to extract "Automation Admin" from the below JSON output I am getting but it gives me JSONObject["Name"] not found exception.

JSON Result

Below is the code snippet. Code snippet

I tried replacing ownerName = json.getJSONArray("records").getJSONObject(i).getString("Name"); with ownerName = json.getJSONArray("records").getJSONObject(i).getString("Owner"); but even that fails. I am able to print values of OwnerId, FirstName etc but not Name. How can I extract 'Automation Admin'?

Afsal
  • 404
  • 3
  • 7
  • 24
  • 2
    It's not a field of the root record object, but the Owner item - so `json.getJSONArray("records").getJSONObject(i).getJSONObject("Owner").getString("Name")` or something similar – josh.trow Feb 13 '20 at 17:42
  • That worked. You saved my day. Thanks :) – Afsal Feb 13 '20 at 17:44

1 Answers1

1

You have to use ownerName = json.getJSONArray("records").getJSONObject(i).getJSONObject("Owner").getString("Name")

Mike
  • 2,547
  • 3
  • 16
  • 30