Apex - get values in nested JSON
Use serialization/deserialization and it's quite easy. You can generate the definitions using JSON2Apex, but it's not rocket surgery and I typically prefer to do it by hand. For example you might do:
public class MyPayload
{
public class Result
{
public final String uniqueId;
public final IdInformation idInformation;
public final BioInformation bioInformation;
}
public class BioInformation
{
final Boolean confidInd;
final String ssn, sex, userId;
}
public class IdInformation
{
final String changeIndicator, dataOrigin, entityIndicator, mID, rowId, userId;
final String firstName, lastName, middleName, surnamePrefix;
}
}
Then it's easy to work with the results.
List<MyPayload.Result> results = (List<MyPayload.Result>)JSON.deserialize(
somePayload, List<MyPayload.Result>.class
);
for (MyPayload.Result result : results)
{
system.debug(result.idInformation.firstName);
}