I keep getting Malformed JSON: Expected '[' at the beginning of List/Set error.

Can someone please fix my wrapper class and controller for this JSON response to deserialize it?


    "DataID": "523836000002",
    "DisplayName": "Joe Buddy Guy (W380)",
    "AnotherId": "00010567463",
    "Restrictions": [{
        "Id": 130,
        "From": "2015-07-01T00:00:00",
        "To": "2016-12-31T00:00:00",
        "Reason": "Owner Use"
    "Allocations": [{
        "Year": 2015,
        "Points": 500000
        "Year": 2016,
        "Points": 500000

Here is my current wrapper:

    public class wrapper {

    public class responseResource {

        public String DataID{get; set;}
        public String DisplayName {get; set;}
        public String AnotherId{get; set;}
        public List<aItems> Allocations {get;set;}
        public List<rItems> Restrictions {get;set;}


    public class aItems {

        public Integer Year {get; set;}
        public Integer Points {get; set;}


    public class rItems {

        public Integer Id {get; set;}
        public String From {get; set;}
        public String To {get; set;}
        public String Reason {get; set;}



Here is my current Controller:

public class wrapper_Controller {

public List<wrapper>ConsoleWrapperList{get; set;}
public List<wrapper>getperformCallout(){

ConsoleWrapperList = new List<wrapper>();

HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();

Http http = new Http();

res = http.send(req);

if(res.getStatusCode() == 200 && res.getBody() != null){

ConsoleWrapperList = (List<wrapper>)json.deserialize(res.getBody(),List<wrapper>.class); 


return ConsoleWrapperList;



The root element of the JSON is an object not an array/list so the JSON code should be:

public wrapper.responseResource data {get; set;}


data = (wrapper.responseResource) JSON.deserialize(

with the JSON.deserialize in a method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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