0

I have following type of json

{
  "itemsPerPage" : 1,
  "links" : {
    "next" : ""
  },
  "list" : [ {
    "id" : "19623",
    "resources" : {
      "reports" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "followingIn" : {
        "allowed" : [ "GET", "POST" ],
        "ref" : ""
      },
      "images" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "activity" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "manager" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "social" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "recognition" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "trendingContent" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "trendingPlaces" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "avatar" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "followers" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "colleagues" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "following" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "members" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "self" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "html" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      },
      "extprops" : {
        "allowed" : [ "GET" ],
        "ref" : ""
      }
    },
    "displayName" : ". ..",
    "jive" : {
      "enabled" : true,
      "externalContributor" : false,
      "username" : "",
      "visible" : true
    },
    "name" : {
      "familyName" : "..",
      "formatted" : ". ..",
      "givenName" : "."
    },
    "type" : "person",
    "typeCode" : 3
  } ],
  "startIndex" : 0
}

I need to parse "list" node using wrapper class in apex. But as list is a keyword in apex its is giving me exception. how to parse this ? please help.

1 Answer 1

3

This tool https://json2apex.herokuapp.com/ will handle the naming problem for you.

Or you can use JSON.deserializeUntyped that returns nested maps and lists (that can have arbitrarily named keys such as "list") that you can write code that walks through and pulls out the m.get('list') value into a valid variable name.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .