You need to sign in to do that
Don't have an account?
Devashree Tidke 23
Can I deserialize JSON string if I dont know the type ?
I am trying to store integration response in JSON format in a custom object (CustomResponseObject__c) to improve the performance. When I retrieve the JSON string after deserialization it can be instance of List<customIntegrationWrapperClass> or CustomIntegrationErrorLog__c Object. How do I deserialize the JSON string not knowing the object type ?
I am trying this :
List<Object> storedResponse = (List<Object>)JSON.deserializeUntyped(listCustomResponseObject[0].JSON__c);
if(storedResponse[0] instanceOf customIntegrationWrapperClass){
System.debug('Integration Success !!!'); //This line is never printed :(
}
The following code works :
List<Object> lstObject = (List<customIntegrationWrapperClass>)JSON.deserialize(listCustomResponseObject[0].JSON__c, List<customIntegrationWrapperClass>.class);
Any pointers ?
I am trying this :
List<Object> storedResponse = (List<Object>)JSON.deserializeUntyped(listCustomResponseObject[0].JSON__c);
if(storedResponse[0] instanceOf customIntegrationWrapperClass){
System.debug('Integration Success !!!'); //This line is never printed :(
}
The following code works :
List<Object> lstObject = (List<customIntegrationWrapperClass>)JSON.deserialize(listCustomResponseObject[0].JSON__c, List<customIntegrationWrapperClass>.class);
Any pointers ?
Raj Vakati
i think this is how it will be
Devashree Tidke 23
Thanks but that won't work. Actually my problem is I don't know if the JSON string is going to be of List<customIntegrationWrapperClass> type always, if I had known the type, JSON.deserialize would have directly worked for my requirement.