I am trying to pass a JSON request to my server where the controller encounters an error while converting the JSON to POJO.
JSON Request
{
"request":[
{"name":"mac"},
{"name":"rosy"}
]
}
My controller function
@RequestMapping(value = "/namelist",
method = RequestMethod.POST,
consumes = { "application/json" },
produces = {"application/json"})
public ... postNameList(@RequestBody NameList names) {}
Public Class NameList extends ArrayList<Name> {}
Public Class Name { private name; ...}
Error
message: "Could not read JSON: Can not deserialize instance of com.abc.xyz.mypackage.NameList out of START_OBJECT token at [Source: org.eclipse.jetty.server.HttpConnection$Input@79aac24b{HttpChannelOverHttp@1d109942{r=1,a=DISPATCHED,uri=/namelist},HttpConnection@2cbdcaf6{FILLING},g=HttpGenerator{s=START},p=HttpParser{s=END,137 of 137}}; line: 1, column: 1]
I am not sure what's wrong with the code. I am fairly new to Spring so any help is appreciated.