+ Start a Discussion
Anil IngleAnil Ingle 

How to deserialize json formatted data into list of class?

[
   {
      "currentPage":"1",
      "totalPages":"37",
      "showingResults":"1-10 of 776"
   },
   {
      "rfqs":[
         {
            "opened":"04/17/2017",
            "clientId":"5004",
            "agentId":"724",
            "serialNumber":"4664641342",
            "opportunityId":"",
            "locReqs":[
               {
                  "1":{
                     "locReqId":"123456",
                     "product_type":"Internet",
                     "access_type":"20M FastE",
                     "SingleLineAddress1":"Street2, CA 92373",
                     "SingleLineAddress2":"",
                     "Term":"12"
                  },
                  "2":{
                     "locReqId":"123489",
                     "product_type":"Internet",
                     "access_type":"20M FastE",
                     "SingleLineAddress1":"Street3, CA 92373",
                     "SingleLineAddress2":"",
                     "Term":"12"
                  }
               }
            ]
         },
         {
            "opened":"04/17/2017",
            "clientId":"5005",
            "agentId":"725",
            "serialNumber":"4664641341",
            "opportunityId":"",
            "locReqs":[
               {
                  "1":{
                     "locReqId":"123412",
                     "product_type":"Internet",
                     "access_type":"20M FastE",
                     "SingleLineAddress1":"Street1, CA 92373",
                     "SingleLineAddress2":"",
                     "Term":"12"
                  }
               }
            ]
         }
      ]
   }
]
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Anil Ingle,

May I request you to please refer the below link for reference.to deserialize a JSON list in Apex. I hope it will be helpful.

Please mark it as best answer if the information is informative.

Best Regards
Rahul Kumar

 
BALAJI CHBALAJI CH
Hi Anil,

Firstly, you need to create a Apex which will store the date of from JSON after deserialize. You can use below links to create the Apex class.
https://www.adminbooster.com/tool/json2apex
https://json2apex.herokuapp.com/

Once the class is saved in the Org you can deserialize the JSON like below:
List<JsonToApex> accounts = (List<JsonToApex>) JSON.deserialize(JsonString, List<JsonToApex>.class);

Here "JsonToApex" is the name of teh Apex class created and "JsonString" is the variable containing JSON response in string format.

Let me know if that helps you.
BALAJI