You need to sign in to do that
Don't have an account?
Varsha D 9
desearilaization the json data
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('https://demo1691926.mockable.io/Api12');
req.setHeader('Content-Type', 'application/json');
HttpResponse response = h.send(req);
system.debug('response : '+response.getBody());
String json1= response.getBody();
DesearlizingJson desearilize1=(DesearlizingJson) Json.deserialize(json1,DesearlizingJson.Class);
System.debug('Phone is' +desearilize1.phone);
System.debug('name is' +desearilize1.name);
Wrapper class
public class DesearlizingJson {
public Decimal phone;
public String name;
public Decimal mobile;
}
json:
{
"Phone":75645433221,
"name":"var",
"mobile":8766555544
}
ouput is:
phone is :87675565
name is : varsha
i need help how to retrieve (i,e Expected output:)
phone:8898999
name:varsha
i,e how to retrive both key and its corresponding value in debug log
Thanks in Advance
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint('https://demo1691926.mockable.io/Api12');
req.setHeader('Content-Type', 'application/json');
HttpResponse response = h.send(req);
system.debug('response : '+response.getBody());
String json1= response.getBody();
DesearlizingJson desearilize1=(DesearlizingJson) Json.deserialize(json1,DesearlizingJson.Class);
System.debug('Phone is' +desearilize1.phone);
System.debug('name is' +desearilize1.name);
Wrapper class
public class DesearlizingJson {
public Decimal phone;
public String name;
public Decimal mobile;
}
json:
{
"Phone":75645433221,
"name":"var",
"mobile":8766555544
}
ouput is:
phone is :87675565
name is : varsha
i need help how to retrieve (i,e Expected output:)
phone:8898999
name:varsha
i,e how to retrive both key and its corresponding value in debug log
Thanks in Advance
Hi,
You can take references from the below code.
Please mark it as the Best Answer so that other people would take references from it.
Thank You