function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
juppyjuppy 

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!
ShashankShashank (Salesforce Developers) 
Hi,

Please refer following thread:

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008r36IAA

Thanks,
Shashank