简体   繁体   English

如何从邮递员发送 JSON 以获取自定义 VO

[英]How to send JSON from postman for a custom VO

What is the format of JSON that I should be sending from Postman to correctly map it to my rest controller.我应该从 Postman 发送的 JSON 格式是什么才能正确地将它映射到我的 rest 控制器。

TfundsVO :
BigDecimal accountNum
String accountName
BigDecimal accountBal



@GetMapping("/")
public ResponseEntity<Object> getFunds(@RequestBody TfundsVO tfundsVO) {
    System.out.println(tfundsVO.getAccountNum());
}

Sample JSON used:使用的示例 JSON:

{
    "tfundsVO": [
     {
        "accountName": "Sam"
     } 
  ]
}

When I tried the above JSON from Postman, call goes to the getFunds method, however all the values in TfundsVO are NULL.当我从 Postman 尝试上述 JSON 时,调用转到 getFunds 方法,但是 TfundsVO 中的所有值都是 NULL。

Just send the payload without an array只需发送没有数组的有效负载

{ "account name": "test" }

And please add an application/json header as a content-type并请添加一个 application/json 标头作为内容类型

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM