Thanks For Reply, If Dont Mine Could please Send Me Entire Code Please Iam Trying to this code
public class JSONParserUtilt { @future(callout=true) public static void parseJSONResponse() { HttpRequest req= new HttpRequest(); req.setMethod('POST'); String username = 'kullayappa.adapala@config-consultants.com'; String password = 'Kull@i12345'; Blob headerValue = Blob.valueOf(username + ':' + password); String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue); req.setHeader('Authorization', authorizationHeader); Http http = new Http(); String url = 'https://cacf-test.crm.us2.oraclecloud.com/crmCommonApi/resources/latest/accounts'; req.setEndpoint(url ); HttpResponse res = http.send(req); //return res.getBody(); System.debug('@@@@@@@@@@@@'+res.getBody());
// Parse JSON response to get all the totalPrice field values. JSONParser parser = JSON.createParser(res.getBody()); Double grandTotal = 0.0; while (parser.nextToken() != null) { if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'PartyId')) { // Get the value. parser.nextToken(); System.debug('44444444444444444'+parser.getCurrentName());
// Compute the grand total price for all invoices. grandTotal += parser.getDoubleValue(); }else{ System.debug('********************'+parser.getText());
This should get your job done!
Ref : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm
- Harsha
Thanks For Reply, If Dont Mine Could please Send Me Entire Code Please Iam Trying to this code
public class JSONParserUtilt {
@future(callout=true)
public static void parseJSONResponse() {
HttpRequest req= new HttpRequest();
req.setMethod('POST');
String username = 'kullayappa.adapala@config-consultants.com';
String password = 'Kull@i12345';
Blob headerValue = Blob.valueOf(username + ':' + password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
Http http = new Http();
String url = 'https://cacf-test.crm.us2.oraclecloud.com/crmCommonApi/resources/latest/accounts';
req.setEndpoint(url );
HttpResponse res = http.send(req);
//return res.getBody();
System.debug('@@@@@@@@@@@@'+res.getBody());
// Parse JSON response to get all the totalPrice field values.
JSONParser parser = JSON.createParser(res.getBody());
Double grandTotal = 0.0;
while (parser.nextToken() != null) {
if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
(parser.getText() == 'PartyId')) {
// Get the value.
parser.nextToken();
System.debug('44444444444444444'+parser.getCurrentName());
// Compute the grand total price for all invoices.
grandTotal += parser.getDoubleValue();
}else{
System.debug('********************'+parser.getText());
}
}
system.debug('>>>>>>>>>>>>>>>>>>>>>>>' + grandTotal);
}
}