spring - Bad deserialize with jackson -
i try call url accept list.
data sent
{"contactavailableidlist":["1"],"contactidlist":["2","3"]} method on server @requestmapping(value = "/lodgers/{lodgerid}/associate/dissociate/contact", method = requestmethod.put) public void associatelodgerandcontact(@pathvariable("lodgerid") long lodgerid, @requestbody @valid final list<long> contactidlist, @requestbody @valid final list<long> contactavailableidlist) { lodgerservice.associatedissociatelodgerandcontact(lodgerid, contactidlist, contactavailableidlist); }
"{"timestamp":1445958336633,"status":400,"error":"bad request","exception":"org.springframework.http.converter.httpmessagenotreadableexception","message":"could not read document: can not deserialize instance of java.util.arraylist out of start_object token\n @ [source: java.io.pushbackinputstream@5a1edae4; line: 1, column: 1]; nested exception com.fasterxml.jackson.databind.jsonmappingexception: can not deserialize instance of java.util.arraylist out of start_object token\n @ [source: java.io.pushbackinputstream@5a1edae4; line: 1, column: 1]","path":"/rest/lodgers/1/associate/dissociate/contact"}"
well not sure, if can accept more requestbodies @ once.
standard way have class
public class contact{ list<long> contactidlist; list<long> contactavailableidlist; }
and accept as
@requestbody @valid contact contact
also receiving array of string , try save them array of long. not sure either, if jackson tries implicitly transform string elements of array long in such case.
Comments
Post a Comment