首页 > 解决方案 > 如何在邮递员中发送包含数组列表的对象

问题描述

我正在用 springboot rest API 做一个项目。我的控制器类如下所示,

@RequestMapping(value = "/artdimfil", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
    @ResponseBody
    public boolean saveArticleDimFilter(@RequestBody ArtDimFil artDimFil)

我想在邮递员中发送以下有效负载,

{
    "id": "b30d1486-04c8-4acc-8d14-8604c81accab",
    "docIdentifier": {
        "recType": "ABC",
        "accesslist": [
         {
        "userid": "xyz@abc.com",
        "role": "abc",
        "status": "Active",
        "actiondate": "2020-07-03T17:59:34.600+0000",
        "name": "XYZ",
      }]
    }
}

但它给出了错误说法

[org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `com.ibm.epm.next.model.Accesslist` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.ibm.epm.next.model.Accesslist` out of START_ARRAY token.

请建议我该怎么做。

标签: javaspring-bootpostman

解决方案


它试图反序列化为“AccessList” - 但我认为它没有使用您的“AccessList”,因为错误说:无法反序列化实例com.ibm.epm.next.model.Accesslist

我建议你重命名你的类,或者确保你有正确的导入语句。您应该导入自己的“AccessList”类。


推荐阅读