You need to sign in to do that
Don't have an account?
NSK000
How to get data from JSON into salesforce
I need to get the data from JSON into salesforce object(custom object).
Following is the JSON -
{"EMPL_TYPE":" ","GRADE":"19","STD_HOURS":40.00,"EMPLID":"JCSD"}
I have a custom object in salesforce and I need to get the above values into their respective fields when i click a button on the custom object.
My code is as follows-
public class Empdetails {
public String EMPL_TYPE;
public String GRADE;
public Double STD_HOURS;
public String EMPLID;
public static Empdetails parse(String EMPLID) {
Http httpProtocol = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('xyz'+EMPLID);
request.setMethod('GET');
HttpResponse response = httpProtocol.send(request);
system.debug(response.getBody());
String jsonString = response.getBody();
// Parse JSON response to get all the Employee record details
JSONParser parser = JSON.createParser(response.getBody());
return (Empdetails) System.JSON.deserialize(EMPLID, Empdetails.class);
}
}
Actually I'm new to this concept. Am I doing correct ? Please suggest me some inputs.
Thank you
Following is the JSON -
{"EMPL_TYPE":" ","GRADE":"19","STD_HOURS":40.00,"EMPLID":"JCSD"}
I have a custom object in salesforce and I need to get the above values into their respective fields when i click a button on the custom object.
My code is as follows-
public class Empdetails {
public String EMPL_TYPE;
public String GRADE;
public Double STD_HOURS;
public String EMPLID;
public static Empdetails parse(String EMPLID) {
Http httpProtocol = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint('xyz'+EMPLID);
request.setMethod('GET');
HttpResponse response = httpProtocol.send(request);
system.debug(response.getBody());
String jsonString = response.getBody();
// Parse JSON response to get all the Employee record details
JSONParser parser = JSON.createParser(response.getBody());
return (Empdetails) System.JSON.deserialize(EMPLID, Empdetails.class);
}
}
Actually I'm new to this concept. Am I doing correct ? Please suggest me some inputs.
Thank you
https://wedgecommerce.com/json-parsing-salesforce/
http://blog.adityanaag.com/22/Parsing+JSON+the+easy+way+using+Apex
http://salesforce-walker.blogspot.com/2013/08/json-parser-example.html
http://www.sfdcstuff.com/2015/06/parsing-json-in-apex.html
http://www.salesforcenextgen.com/how-to-do-json-parsing-of-a-wrapper-class-in-salesforce/
https://github.com/Trigger2991/SFDC-JSON-Parser
Do you have any idea how to call this class using a button?