如果我不需要它,我怎么能忽略它?我只需要账单。
如果我从 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 对象 Bill
@PostMapping("/bill")
@ResponseBody
public ResponseEntity<String> getBill(@RequestBody Bill bill)
守候你守候我
相关分类