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!