遇到了一个很奇葩的问题,具体是这样的:
postman 通过 post 方式发送请求,请求参数是一个嵌套的json,后端是@RequestBody修饰的实体类接参的,
具体的json数据:文章来源:https://www.toymoban.com/news/detail-765711.html
{
"ipAddress":"192.168.110.179",
"ipv6Address":"::",
"portNo":"38050",
"protocol":"HTTP",
"macAddress":"ec:c8:9c:c4:5c:b3",
"channelID":"1",
"dateTime":"2021-12-14T19:23:52+08:00",
"activePostCount":"157",
"eventType":"ANPR",
"eventState":"active",
"eventDescription":"ANPR",
"channelName":"IP CAPTURE CAMERA",
"deviceID":"jnjtzf0001",
"aNPR":{
"licensePlate":"车牌",
"line":"1",
"confidenceLevel":"0",
"plateType":"unknown",
"plateColor":"blue",
"licenseBright":"0",
"pilotsafebelt":"unknown",
"vicepilotsafebelt":"unknown",
"pilotsunvisor":"unknown",
"vicepilotsunvisor":"unknown",
"envprosign":"unknown",
"dangmark":"unknown",
"uphone":"unknown",
"pendant":"unknown",
"tissueBox":"unknown",
"label":"unknown",
"decoration":"unknown",
"plateCharBelieve":"0",
"speedLimit":"0",
"illegalInfo":{
"illegalCode":"0"
},
"vehicleType":"unknown",
"featurePicFileName":"1",
"detectDir":"8",
"detectType":"1",
"barrierGateCtrlType":"0",
"alarmDataType":"0",
"dwIllegalTime":"0",
"vehicleInfo":{
"color":"white"
},
"gPSInfo":{
"longitude":{
"degree":"117",
"minute":"6",
"sec":"49.910000"
},
"latitude":{
"degree":"117",
"minute":"6",
"sec":"49.910000"
}
}
},
"UUID":"602cf998-1dd2-11b2-a842-be6ebc977415",
"picNum":"1"
}
后端:
大家知道以上事例即可。
出现的问题是: 发送请求后,没能收到外层实体类的参数,内层的ANPR对象,一直是 null .
解决的方式是: 给该属性添加注解 @JsonProperty(“aNPR”)
注:有时候接收的项目,不是很规范,请大大多多留意!!!文章来源地址https://www.toymoban.com/news/detail-765711.html
到了这里,关于postman发送json嵌套, 后端 @RequestBody 接收不到的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!