+ Start a Discussion
sandeep reddy 37sandeep reddy 37 

about json can u tell me any one

i write programe about transforing data from json to class the code is 
public class jsonclass {
    public string result{set;get;}
    public jsonclass(){
              string jso ='{"name":"suriprakesh","age":20,"salary":20000}';
    map<string,list<string>> m = (map<string,list<string>>)JSON.deserializeuntyped(jso);
        }
    
    }
       its getting run time error that is just tell me please  
Amit Chaudhary 8Amit Chaudhary 8
PLease check below post to convert JSON to Apex
1) 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.
public 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);
		}
	}

    
}

For more information on REST class please check below post
1) http://amitsalesforce.blogspot.in/search/label/Rest%20API

Let us know if this will help you
Thanks
Amit Chaudhary