Advertisement
Kenji776

Deserialize object with generic object list

Dec 10th, 2012
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. //this compiles, but throws error:
  2. //'System.TypeException: Invalid conversion from runtime type LIST<ANY> to LIST<SObject>'
  3. //when trying to create the list of contacts the object data.
  4.  
  5. Map<String, Object> createResponse = (Map<String, Object>)JSON.deserializeUntyped(RestContext.response.responseBody.toString());
  6.        
  7. list<sobject> createResponseContacts = (list<sobject>) createResponse.get('sObjects');
  8.  
  9. Contact c = (contact) createResponseContacts[0];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement