I have am trying to deserialize a JSON object within a JSON Object, what I am wondering is do I have to deserialize the response twice somehow?

Does anyone have any examples of how to do this? What I am trying to get out of the sample below is the two uuids. One is the in the main response body and the second is layered in a location object.

  "link": {
    "url": "https://api.fieldaware.net/customer/4d18011294364a85a1c5541b9b4a0eee",
    "rel": "detail"
  "location": {
    "link": {
      "url": "https://api.fieldaware.net/location/3b0fd4f427ac47bfa02c956a8f3179c9",
      "rel": "detail"
    "uuid": "4a1de64d6b184abfb5692d2443dfa4d2",
  "uuid": "3b0fd4f427ac47bfa02c956a8f3179c9",
  "email": "user10@glidebooks.com",
  "firstName": "Blaise",
  "lastName": "Champlin",
  "locale": "en_US",
  "phone": null,
  "platform": "ios",
  "role": "Admin",
  "timezone": "Europe/Dublin",
  "customFields": {},

What you have posted is not valid JSON because of extra trailing commas before a couple of closing }. If that is just a cut and paste error, you can parse the JSON conventionally e.g. using the code generated by JSON2Apex. The JSON.deserialize method used by that generated code will handle nested objects automatically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.