无法解析包含两个简单字段和一个对象的 json 字符串。我使用杰克逊库。我总是得到 400 错误
JSON:
{
"id": "",
"categories": "{"name":"Sport","id":1}",
"name": "sdsd"
}
控制器:
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<String> createCategory(HttpServletRequest request, @RequestBody Polls polls) {
pollsService.add(polls);
URI uri = new UriTemplate("{requestUrl}/{username}").expand(request.getRequestURL().toString(), polls.getId());
final HttpHeaders headers = new HttpHeaders();
headers.put("Location", Collections.singletonList(uri.toASCIIString()));
return new ResponseEntity<String>(headers, HttpStatus.CREATED);
}