function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhish ChalkeAbhish Chalke 

how to fetch a particular record from JSON parse

i am getting parsed data from this 
wrapperlhscount wlc = hrwdLocationHealthStatusTileController.parse(res.getBody());

my response is 
{
    "transactionSequenceId": "w465t4564hfgdys547ue54",
    "code": "200",
    "subCode": "1000",
    "status": "Success",
    "message": "OK",
    "parentCompanyId": "SWC",
    "responseData": {
        "locationHealthStatusList": [
            {
                "companyId": "SWC",
                "parentCompanyId": "SWC",
                "family": "Managed Router Services",
                "status": "Normal",
                "statusCount": 3994
            },
            {
                "companyId": "SWC",
                "parentCompanyId": "SWC",
                "family": "Managed Router Services",
                "status": "Backup Down",
                "statusCount": 39
            }
  
        ]
    }
}
I wanted to fetch statusCount from the response 
how should I fetch this 
in wlc variable I am getting parsed data
 
SwethaSwetha (Salesforce Developers) 
HI Abhish,
The JSON Response needs to be deserialized and then assigned to a String variable.
In the context of Apex, you can define an Apex class and then deserialize the JSON string into the class. Then testData1 is just a property of the class;
public class TestData {
    public String testData1 {get; set;}
    public String testDat2 {get; set;}
}
TestData data = (TestData) JSON.deserialize(jsonString, TestData.class);
String var1 = data.testData1;

Or you can simply deserialize the JSON string into a map using the deserializeUntyped method: 
Map<String, Object> m = (Map<String, Object>) JSON.deserializeUntyped(jsonString);
String var1 = (String) m.get('testData1');

Recommend reviewing the examples provided in below posts to get started:

https://salesforce.stackexchange.com/questions/327930/getting-a-value-form-json-and-store-in-a-variable
https://salesforce.stackexchange.com/questions/273922/how-can-i-save-fetched-json-to-a-custom-objects-custom-field-json-parameters-d
https://stackoverflow.com/questions/62261252/apex-salesforce-read-json-from-response-and-store-it-in-a-string-variable

If this information helps, please mark the answer as best. Thank you
Abhish ChalkeAbhish Chalke
hi I tried using deserializeUntyped but it is giving me error
map <string,object> JSONbody =(map <string,object>)json.deserializeUntyped(res.getBody());
         system.debug('JSON BODY'+JSONbody);
         Map<String, Object> dim =(Map<String, Object>)JSONbody.get('responseData');
         System.debug('dim'+dim);
         for( Object o : dim) {
            Map<String, Object> castedObject = (Map<String, Object>)o;
            List<Object> sffFieldNames = o.get('locationHealthStatusList');
            for( Object o1 : sffFieldNames) {
              Map<String, Object> newCast = (Map<String, Object>)o1;
              Object acct = o1.get('statusCount');
              system.debug('statusCount'+statusCount);
            }
          }