Jira API - Deserialization Issue with START_ARRAY Token

Hello everyone, I hope my English is okay! I’m developing an application that interacts with the Jira API, and I’m encountering an error that states “Cannot deserialize instance of Jira from START_ARRAY token”.

The JSON data I receive looks like this:

[
    {
        "expand": "description,lead,url,projectKeys",
        "self": "http://",
        "id": "10802",
        "key": "TE",
        "name": "TEST TEST",
        "avatarUrls": {
            "48x48": "http://",
            "24x24": "http://",
            "16x16": "http://",
            "32x32": "http://"
        },
        "projectCategory": {
            "self": "http://",
            "id": "10200",
            "name": "TTTTTT",
            "description": "TTTTTTTT"
        },
        "projectTypeKey": "software"
    },
    {
        "expand": "description,lead,url,projectKeys",
        "self": "http://",
        "id": "10801",
        "key": "TT",
        "name": "TREINAMENTO TESTE",
        "avatarUrls": {
            "48x48": "http://",
            "24x24": "http://",
            "16x16": "http://",
            "32x32": "http://"
        },
        "projectTypeKey": "business"
    }
]

Here’s the relevant part of my code:

public class Project {
    private String expand;
    private String self;
    private int ID;
    private String key;
    private String name;
    private Avatar avatarUrls;
    private ProjectCategory projectCategory;
    private String projectTypeKey;

//getters and setters
}

public class Jira {
    private ArrayList<Project> projects;

    public Jira() {
    }

    public ArrayList<Project> getProjects() {
        return projects;
    }

    public void setProjects(ArrayList<Project> projects) {
        this.projects = projects;
    }
}

public class Application {
   public static void main(String args[]) throws IOException {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders header = new HttpHeaders();
        header.set("Authorization", "Basic XXXXXXXXX");
        header.set("app_token", "XXXXXXXXX");
        HttpEntity entity = new HttpEntity(header);
        ResponseEntity<Jira> result = restTemplate.exchange("URL", HttpMethod.GET, entity, Jira.class);
        System.out.println(result.getBody().toString());
    }
}

Does anyone have suggestions on how to resolve this issue? Thanks a lot!

yeah, the problem’s clear - you’re trying to map an array straight to a single object. since Jira returns [{...}, {...}], just use ResponseEntity<List<Project>> instead of that Jira wrapper class. the START_ARRAY error pops up when Jackson expects an object but gets an array.

Your JSON response is an array of Project objects, but you’re trying to deserialize it into a Jira object. The API returns a collection of projects, not a wrapper with a projects field. You need to handle the array structure directly. Change your main method to deserialize into an array or list of Project objects: ResponseEntity<Project> result = restTemplate.exchange(“URL”, HttpMethod.GET, entity, Project.class); Or use TypeReference with Jackson’s ObjectMapper to deserialize into ArrayList. You don’t need the Jira wrapper class since the API endpoint returns projects as a root array, not nested in another object.

Had this exact problem six months ago with REST APIs. Jackson can’t handle the mismatch between what you expect and the actual JSON array format. You’re getting a direct array of projects, so you’ve got two options. Change your RestTemplate call to expect Project[] directly, or use ParameterizedTypeReference<List<Project>> with the exchange method if you want Lists. I went with the List approach - it’s more flexible for processing later. You don’t need that Jira wrapper class since the API doesn’t wrap the projects array in another object. Once you match your expected type with the actual JSON structure, deserialization works fine.