You need to sign in to do that
Don't have an account?
Vasavi Vajinepalli
Need to fetch one field from response of http callout
Hi,
I am getting the below response from a http callout.
{\"response\" : [{\"status\" : \"success\", \"type\" : \"success\", \"code\" : \"E0\", \"message\" : \"success\"}]}"
I need to retrieve "code" : "E0". Can anyone help me in retreiving this value?
Thanks,
vasavi
I am getting the below response from a http callout.
{\"response\" : [{\"status\" : \"success\", \"type\" : \"success\", \"code\" : \"E0\", \"message\" : \"success\"}]}"
I need to retrieve "code" : "E0". Can anyone help me in retreiving this value?
Thanks,
vasavi
I think this is your json response, use the below class to retrieve the field.
{
"response": [
{
"status": "success",
"type": "success",
"code": "E0",
"message": "success"
}
]
}
public class fromJSON{
public cls_response[] response;
class cls_response {
public String status; //success
public String type; //success
public String code; //E0
public String message; //success
}
public static fromJSON parse(String json){
return (fromJSON) System.JSON.deserialize(json, fromJSON.class);
}
}
Thanks for the solution. Is there any way like not to create a new class for deserializing. I mean is there any way to implement this in the same classs in which am posting the data?
thanks,
vasavi
More over you can't have 2 level deep in apex class.