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

Cannot deserialize instance of <unknown> from null value null or request may be missing a required field
Hi All,
I'm unable to deserialize a string even when the value is not null. Here is my code snippet.
public static List<ObjectA> processSelected(String constr) {
system.debug('constr===>'+constr); //getting value in this
List<dupeContact> conList = (List<dupeContact>)JSON.deserialize(constr, List<dupeContact>.class);
system.debug('dupeContact====>'+conList);
List<ObjectA> selectedContacts = new List<ObjectA>();
if (conList != null && conList.size() >0) {
for (dupeContact cCon : conList) {
if (cCon.selected == true) {
selectedContacts.add(cCon.con);
}
}
}
Thanks in Advance :)
I'm unable to deserialize a string even when the value is not null. Here is my code snippet.
public static List<ObjectA> processSelected(String constr) {
system.debug('constr===>'+constr); //getting value in this
List<dupeContact> conList = (List<dupeContact>)JSON.deserialize(constr, List<dupeContact>.class);
system.debug('dupeContact====>'+conList);
List<ObjectA> selectedContacts = new List<ObjectA>();
if (conList != null && conList.size() >0) {
for (dupeContact cCon : conList) {
if (cCon.selected == true) {
selectedContacts.add(cCon.con);
}
}
}
Thanks in Advance :)
Can you post the 'constr' string value.
Thanks,
Aman
11:10:35:003 USER_DEBUG [927]|DEBUG|constr===>[{"con":{"Name":"1 Lead Test best","First_Name__c":"1 Lead Test","Last_Name__c":"best","Id":"a00c0000006dIlYAAU","OwnerId":"005c0000003konIAAQ","Phone__c":"1234567890","Evening_Phone__c":"(963) 258-7410","Cell_Phone__c":"(014) 785-2369","Email__c":"test@best.com","Work_Email__c":"testsecondary@best.com","Owner":{"Name":"TestApps","Id":"005c0000003konIAAQ"}},"selected":true},{"con":{"Name":"1 Lead Test 2 best","First_Name__c":"1 Lead Test 2","Last_Name__c":"best","Id":"a00c0000006dIlJAAU","OwnerId":"005c0000003konIAAQ","Owner":{"Name":"TestApps","Id":"005c0000003konIAAQ"}},"selected":true},{"con":{"Name":"1 Lead Test 2 best","First_Name__c":"1 Lead Test 2","Last_Name__c":"best","Id":"a00c0000006dIkzAAE","OwnerId":"005c0000003konIAAQ","Owner":{"Name":"TestApps","Id":"005c0000003konIAAQ"}},"selected":false},{"con":{"Name":"1 Lead Test best","First_Name__c":"1 Lead Test","Last_Name__c":"best","Id":"a00c0000006dIkuAAE","OwnerId":"005c0000003konIAAQ","Owner":{"Name":"TestApps","Id":"005c0000003konIAAQ"}},"selected":false},{"con":{"Name":"1 Lead Test best","First_Name__c":"1 Lead Test","Last_Name__c":"best","Id":"a00c0000006dLmzAAE","OwnerId":"005c0000003konIAAQ","Email__c":"test@best.com","Work_Email__c":"testsecondary@best.com","Owner":{"Name":"TestApps","Id":"005c0000003konIAAQ"}},"selected":false}]
Hi lavanya mulpuri,
Please try this for deserialization. Hope it will help you.
Mark as a best if it will help you.
Regards,
Suraj
It's throwing a run time error "FATAL_ERROR System.TypeException: Invalid conversion from runtime type List<ANY> to List<FindDupeLeads_Lightning.dupeContact>"
Please let me know if there's any other alternative.
Thanks!
Please use below code it may help you.
List<dupeContact> conList = (List<dupeContact>) JSON.deserializeUntyped(List<dupeContact>,dupeContact.class);
List<dupeContact> conList = (List<dupeContact>) JSON.deserialize(List<dupeContact>,dupeContact.class);
List<dupeContact> conList = (List<dupeContact>) JSON.deserializeStrict(List<dupeContact>,dupeContact.class);
Please let me know in case of any other assistance.
Thanks
Varaprasad
Can you tell me where exactly should I pass the constr, which contains the JSON String. And the syntaxes you've mentioned are throwing multiple compile time errors.
Thanks!
Did you get this resolved ? I have the same error.