Hi all
I started using the android rest template and i got a failure i dont understand.
There i try to get these json objects into my Task array.Code:RestTemplate tmpl = new RestTemplate(); tmpl.setRequestFactory(new HttpComponentsClientHttpRequestFactory()); List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(new MappingJacksonHttpMessageConverter()); tmpl.setMessageConverters(messageConverters); Task[] tr = tmpl.getForObject("http://10.1.201.167:3001/todo", Task[].class);
This class looks like this:
I always get a JsonMappingException: Can not construct instance of ch.company.android.Task, problem: no suitable creator method found to deserialize from Json StringCode:@JsonIgnoreProperties(ignoreUnknown = true) public class Task { private String _id; private String title; private String description; private Date createdAt; public Task() { super(); } public Task(JsonParser parser, DeserializationContext ctx) { super(); } public Task(String str, String a, String b, String c){ super(); } public Task(String id, String title, String description, Date createdAt){ super(); } @JsonProperty("_id") public String getId() { return _id; } @JsonProperty("_id") public void setId(String id) { _id = id; } @JsonProperty("created_at") public Date getCreatedAt() { return createdAt; } @JsonProperty("created_at") public void setCreatedAt(Date createdAt) { this.createdAt = createdAt; } @JsonProperty("title") public String getTitle() { return title; } @JsonProperty("title") public void setTitle(String title) { this.title = title; } @JsonProperty("description") public String getDescription() { return description; } @JsonProperty("description") public void setDescription(String description) { this.description = description; } }
What am i doing wrong?
Oh and none of these Constructors is called.


Reply With Quote