I'm building a PATCH service where I'm trying to deserlize into a JSON payload that has different levels.
{
"ShippingAddress": {
"Country": "United States",
"PostalCode": "80202",
"StateOrProvince": "CO",
"Street": "Testing Street 123",
"City": "Denver"
},
"BillingAddress": {
"Country": "United States",
"PostalCode": "80202",
"StateOrProvince": "Colorado",
"Street": "123 Main St 1122",
"City": "Denver"
},
"Person": {
"LastName": "Dan20140214c",
"IsPrimary": true,
"FirstName": "Dan20140214c",
"Email": "[email protected]",
"Phone": "5511555555555",
"MemberType": "Guest Traveler"
},
"MobilePhone": "5555555555 ",
"DryFlyAccountID": 120919,
"ActivePURL": "",
"AccountParentID": ""
}
I'm trying to put this into a Map<String, Object> castedBody = (Map<String, Object>)JSON.deserializeUntyped(requestBody);
which works for everything else but I need some guidance on how to traverse the nodes inside the object. I have control over this service so I can flatten out the payload I'm just trying to make the payload as clean as possible.
When I deserialize it looks like this
{AccountParentID=, ActivePURL=, BillingAddress={City=Denver, Country=United States, PostalCode=80202, StateOrProvince=Colorado, Street=123 Main St 1122}, DryFlyAccountID=120919, MobilePhone=5555555555 , Person={[email protected], FirstName=Dan20140214c, IsPrimary=true, LastName=Dan20140214c, MemberType=Guest Traveler, Phone=9995959595}, ShippingAddress={City=Denver, Country=United States, PostalCode=80202, StateOrProvince=CO, Street=Testing Street 123}}
containsKey()
checks you end up doing and the depth of your logic tree.