In this post I'm going to explain how to create a Wrapper class to Parse the JSON Response in Apex which contains key and value pair in JSON.
JSON String:
{ "status": "SUCCESS", "errors": [], "data": { "oldCaseStatus": "Case_CANCELLATION_success", "newCaseStatus": "Case_CANCELLATION_success", "NewCaseNumber": "3732gy12" } }
Apex Class:
public class ParsingTest { public ParsingTest() { String json='{"status":"SUCCESS","errors":[],"data":{"oldCaseStatus":"Case_CANCELLATION_success","newCaseStatus":"Case_CANCELLATION_success","NewCaseNumber":"3732gy12"}}'; ParsingWrapper apiRespone = new ParsingWrapper(); apiRespone = (ParsingWrapper)System.JSON.deserialize(json,ParsingWrapper.class); System.debug('apiRespone..'+apiRespone); } //Wrapper Class For Parsering
public class ParsingWrapper { public String status{get;set;} public Map<String,String> data{get;set;} public Cls_errors[] errors; } public class Cls_errors { } }
Hope this helps you....Enjoy!
No comments:
Post a Comment