1

When deserializing a JSON string to List<Object> using JSON.deserializeUntyped( resParams ) the list received is incomplete:

{Address=null, BillingAddress=2509, CompanyId=632, County=null, Fax=null, Id=2509, PostCode=null, ShortName=Test Site Ignore, SiteName=Test Site Ignore, Telephone=null, ...}

As you can see we get 10 elements and an ellipsis indicating missing elements. Is there a way to get all (12 )elements with deserialize()?

3

The problem isn't JSON.deserialize, it's Object.toString. Basically, when you debug a non-String, non-null item, System.debug calls Object.toString, which has the behavior of truncating big objects so they don't take up a ton of log space. There's no convenient way to debug the entire object. However, if you use checkpoints, you can open the checkpoint to observe the object's entire state by way of the checkpoint GUI, or you can convert your object back to a String and debug that via JSON.serialize(JSON.deserializeUntyped(resParams)).

  • Thanks for such a prompt answer, is there a way to use those missing elements that are in an ellipsis? Unfortunately, I can't pass them into say a SF field. E.g. Town = 'London' is hidden in the ellipsis and I cannot pass it into the SF field. Is there any other way to retrieve all the fields? – Alan Abishev Dec 20 '16 at 16:15
  • @Baraban Either re-serialize them, or you could process the results via something like Map<String, Object> values = (Map<String, Object>)JSON.deserializeUntyped(resParams); for(String key: values.keys()) { /* do something with values.get(key) */ } – sfdcfox Dec 20 '16 at 16:17
  • Thanks for your help! Basically, I serialized it and broken it into a map<String,Object> and got all the values in the end. All as you suggested! – Alan Abishev Dec 20 '16 at 16:46

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.