PLease check below post to convert JSON to Apex1) https://www.adminbooster.com/tool/json2apex Please try below code
//
//Generated by AdminBooster
//
public class fromJSON{
public String name; //suriprakesh
public Integer age; //20
public Integer salary; //20000
public static fromJSON parse(String json){
return (fromJSON) System.JSON.deserialize(json, fromJSON.class);
}
static testMethod void testParse() {
String json= '{"name":"suriprakesh","age":20,"salary":20000}';
fromJSON obj = parse(json);
System.assert(obj != null);
}
}
Please try below code.
For more information on REST class please check below post1) http://amitsalesforce.blogspot.in/search/label/Rest%20APILet us know if this will help youThanksAmit Chaudharypublic class jsonclass
{
public string result{set;get;}
public jsonclass()
{
String json='{"name":"suriprakesh","age":20,"salary":20000}';
fromJSON obj = parse(json);
}
public class fromJSON
{
public String name; //suriprakesh
public Integer age; //20
public Integer salary; //20000
public static fromJSON parse(String json){
return (fromJSON) System.JSON.deserialize(json, fromJSON.class);
}
}
}
1 risposta