You need to sign in to do that
Don't have an account?

How to deserialize a list of maps
I have created a list of maps and serialized it into a json string. What I would like to be a able to do is deserialize this string back into the same List of maps that was used to serialize it. Is this possible or is there a workaround I can perfom? thanks
//code
String json = JSON.serialize(masterList);
//test
List<Map<id,sObject> masterList = JSON.deserializeUntyped(json);
//code
String json = JSON.serialize(masterList);
//test
List<Map<id,sObject> masterList = JSON.deserializeUntyped(json);
Try this:
All Answers
If you are looking to deserialize untyped without custom classes (so basically assume the data has the right structure at runtime) you can do it like this:
Example Code:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm#apex_System_Json_deserializeUntyped
Hope this will help you.
Thanks
karthik
System.TypeException: Invalid conversion from runtime type List<ANY> to Map<String,ANY>
(line 1 of your example)
Try this: