Reputation: 3371
I have a JSON format of
var array1 = new Array; var array2 = new Array; //push some string to array1 and array2 var data = JSON.stringify({'email':email,'age':age,'array1':array1,'array2':array2});
How could I map it to POJOs using Jackson JSON Mapper to avoid 400 Bad Request.
I have tried
public class MyPOJOs{ private String email; private String age; private MyList array1; private MyList array2; //getters and setters } public class MyList{ private ArrayList list; //getter and setter }
My controller
public @ResponseBody Response myController(@RequestBody MyPOJOs myPOJOs){ String email = myPOJOs.getEmail(); logger.log("Hi " + email); return null; }
Thanks.
Upvotes: 1
Views: 2296
Reputation: 14549
I do not really know Jackson JSON processor but I would be surprised that it is able to map your arrays to your custom MyList
objects.
I would expect the MyPOJOs
class to have member like private String[] array1
or private List<String> array1
or a Collection
.
btw: There are many mistakes in your code that make me think you do not post real code here. Misspelled type names etc.
Upvotes: 2