I am calling an API from the apex, giving me the following response.

    "status": {
        "error": "no",
        "message": "Successfully updated subscriber"
    "result": {
        "method": "email",
        "_id": "62b1b4d3ca04161d9baf811b",
        "address": "sample.23@gmail.com",
        "meth": "email",
        "statuspage": "62600f07f69a9104dcf7e33e",
        "__v": 0,
        "granular": [
        "active": true,
        "join_date": "2022-06-21T12:08:51.817Z"

How can I parse it so I can use the granular as a list of strings?


1 Answer 1


You can user JSON.deserializeUntyped() to deserialize JSON into Apex collections of primitive values. This will convert JSON into an Object value.

So if you want to get granular List then you can use get method like this:

Map<String, Object> meta = (Map<String, Object>)JSON.deserializeUntyped(jsonString);
Map<String,object> getResult = (Map<String,object>) meta.get('result');
List<Object> granularList = (List<Object>) getResult.get('granular');

Here granularList will have all the data that you want. And if you want the granular List as List<String> then you can convert it like this:

List<string> granularStringList = new List<string> ();
for(Object granularListObj: granularList){

Not the answer you're looking for? Browse other questions tagged or ask your own question.