【发布时间】:2019-12-05 14:53:54
【问题描述】:
如果我不需要它,我如何忽略 rootname?我只需要账单。
如果我从 json 中删除“版本”工作正常..
我在控制台日志上的错误
2019-07-27 19:20:14.874 WARN 12516 --- [p-nio-80-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unexpected token (FIELD_NAME), expected END_OBJECT: Current token not END_OBJECT (to match wrapper object with root name 'bill'), but FIELD_NAME; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (FIELD_NAME), expected END_OBJECT: Current token not END_OBJECT (to match wrapper object with root name 'bill'), but FIELD_NAME
at [Source: (PushbackInputStream); line: 8, column: 2]]
我的 json 看起来像这样
{
"bill":
{
"siteId":"gkfhuj-00",
"billId":"d6334954-d1c2-4b51-bb10-11953d9511ea"
},
"version":"1"
}
我的 json 类 我尝试使用 JsonIgnoreProperties 但它也无济于事,我也写了“版本”
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName(value = "bill")
public class Bill {
private String siteId;
private String billId;
//getters and setters
我的post方法lisen对象比尔
@PostMapping("/bill")
@ResponseBody
public ResponseEntity<String> getBill(@RequestBody Bill bill)
【问题讨论】:
标签: java spring jackson deserialization