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

unable to deserialize
Hello
This is my first post.
I have a json string which I want to deserialize and get the values.
public class CompanyContactsWrapper
{
public string contact{get;set;}
public string postalcode{get;set;}
public string contactnumber{get;set;}
}
public class Jsonexample4
{
public CompanyContactsWrapper CompanyContacts{get;set;}
public Jsonexample4()
{
string jsonInput='{"CompanyContacts":[{"contact":"pn0","postalcode":"0","contactnumber":"pc0"},{"contact":"pn1","postalcode":"1","contactnumber":"pc1"},{"contact":"pn2","postalcode":"2","contactnumber":"pc2"}]}';
CompanyContacts= (CompanyContactsWrapper)JSON.deserialize(jsonInput,CompanyContactsWrapper.class);
system.debug('==>'+CompanyContacts);
}
}
In developer console I create an object and execute.
I get contact=null, postalcode=null & contactnumber=null.
pls tell where I have gone wrong?
thanks
divya manohar
This is my first post.
I have a json string which I want to deserialize and get the values.
public class CompanyContactsWrapper
{
public string contact{get;set;}
public string postalcode{get;set;}
public string contactnumber{get;set;}
}
public class Jsonexample4
{
public CompanyContactsWrapper CompanyContacts{get;set;}
public Jsonexample4()
{
string jsonInput='{"CompanyContacts":[{"contact":"pn0","postalcode":"0","contactnumber":"pc0"},{"contact":"pn1","postalcode":"1","contactnumber":"pc1"},{"contact":"pn2","postalcode":"2","contactnumber":"pc2"}]}';
CompanyContacts= (CompanyContactsWrapper)JSON.deserialize(jsonInput,CompanyContactsWrapper.class);
system.debug('==>'+CompanyContacts);
}
}
In developer console I create an object and execute.
I get contact=null, postalcode=null & contactnumber=null.
pls tell where I have gone wrong?
thanks
divya manohar
Thanks,
Himanshu
All Answers
Thanks,
Himanshu
thanks. it worked.