You need to sign in to do that
Don't have an account?
Corey Edwards 11
Apex Map<String,Object> need to get object values
I have a JSON string:
I've tried addressDetails[0] and addressDetails.addressId but I think I'm approaching this wrong.
Any help would be greatly appreciated.
{addressDetails=({addressId=56941, addressLine1=76 Kilaben Rd, addressLine2=null, addressLine3=null, addressType=H, countryCode=AUS, locality=KILABEN BAY, postcode=2283, sortplan=017, state=NSW, ...}), aliasName=null, concessionInfo=null, contactDate=null, contactDetails=({contactDetail=, contactId=122827, contactType=H, delta=2}), contactPreference={correspondanceLevel=0, correspondanceLevelDescription=null, emailOpt=N, smsOpt=N}, deceasedFlag=N, dob=1952-07-29T00:00:00, firstContactDate=null, firstName=John, ...}I'm mapping this using:
Map<String, Object> meta = (Map<String, Object>) JSON.deserializeUntyped(viewPersonValue);To get firstname I'd say:
meta.get('firstName');The issue I'm facing is accessing the values in addressDetails.
I've tried addressDetails[0] and addressDetails.addressId but I think I'm approaching this wrong.
Any help would be greatly appreciated.
Please find the suggested workaround from the stack exchange community for the same issue.
if you make use of the Apex type system, you will have an easier time working with the data. If you create a class for the incoming data structure, abbreviated as: You will be able to access the data from your JSON strings as so: Hope this helps.
Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.
Thanks,
Nagendra.