无法将JSON数组发布到我的rest控制器

问题描述 投票:0回答:1

我有一个JSON数组,需要在rest控制器处使用。总是说JSON解析器错误

{
"message": "JSON parse error: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token\n at [Source: (PushbackInputStream); line: 1, column: 1]",
"errorUid": "c794a587-2f27-4402-b43b-5ec46a5bccfc"
}   

这是我的请求对象

{ 
"results":[{
    "keyname":"bb-response",
    "bbResponse":{
        "count": 8,
       "transactionId": "hu7h78707ssf8",    
        "responseMessage": [{
             "type": "NTY",
             "status": "F"          
       },
       {
        "type": "HYG",
        "status": "F"           
    }]}
}]}

这是我的控制器代码

    @PostMapping(value = "/post-keys")
@ResponseStatus(HttpStatus.OK)
public String postKeys(@RequestBody List<RequestWrapper> requestWrapperList) {
    log.info("Starting to send messages ");
     return "success";
}

我的RequestWrapper类

 public class RequestWrapper implements Serializable {

      String keyname;
      BBResponse bbResponse;
}

我的BBResponse类别是

 public class BBResponse implements Serializable {
     private int count;
     private List<Response> responseMessage;
     private String transactionId;
}

有人可以让我知道我在哪里做错了吗?任何想法将不胜感激

java spring-mvc post model-view-controller spring-restcontroller
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.