You need to sign in to do that
Don't have an account?
juppy
System.JSONException: Cannot deserialize instance of Address from FIELD_NAME value city
Here's a good one... I have a need to pass a list of sObjects as a JSON string, however the deserialise is failing with the above error when these sObjects are User records. Any ideas?
You can run this code in execute anonymous to reproduce the fault:
SObjectType sObjType = Schema.getGlobalDescribe().get('user');
set<string> set_AllFieldNames = sObjType.getDescribe().fields.getMap().keySet();
string strQuery = 'select ' + String.join(new List<String>(set_AllFieldNames), ', ');
strQuery += ' from user ';
list<sObject> li_sObjects = database.query(strQuery);
string JSONstring = JSON.serialize(li_sObjects);
list<sObject> li_sObjects2 = (list<sObject>) JSON.deserialize(JSONstring, list<sObject>.class);
Thanks in advance!
You can run this code in execute anonymous to reproduce the fault:
SObjectType sObjType = Schema.getGlobalDescribe().get('user');
set<string> set_AllFieldNames = sObjType.getDescribe().fields.getMap().keySet();
string strQuery = 'select ' + String.join(new List<String>(set_AllFieldNames), ', ');
strQuery += ' from user ';
list<sObject> li_sObjects = database.query(strQuery);
string JSONstring = JSON.serialize(li_sObjects);
list<sObject> li_sObjects2 = (list<sObject>) JSON.deserialize(JSONstring, list<sObject>.class);
Thanks in advance!
Please refer following thread:
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008r36IAA
Thanks,
Shashank