JSON parse error: Cannot deserialize instance of `java.util.ArrayList` out o

created at 07-30-2021 views: 940

description

Last week I wrote about the external support of the underlying interface of Dubbo. I took a self-test today. An error occurred during the self-test. This is it.

JSON parse error: Cannot deserialize instance of `java.util.ArrayList` out of VALUE_STRING token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of VALUE_STRING token
 at [Source: (PushbackInputStream); line: 5, column: 14] (through reference chain: com.byai.saas.bywechatbot.api.common.model.request.AddAutoAddTaskRequestV2["hello"])

It probably means that the Java object is an ArrayList, but the format I wrote in JSON cannot be converted, it should be my Json format is wrong.
My JSON was written like this at the beginning

{
    "groupId": 88,
    "taskName": "YourTaskName",
    "companyId": 125540,
    "helloList": "[testGroup]",
    "addAutoWelcomeRequests": 
        {
        "type": 1,
        "content": "hahha",
        "fileUrl": "http:/sssss",
        "fileName": "",
        "linkTitle": "",
        "linkPicUrl": "",
        "linkDesc": "",
        "linkUrl": "",
        "miniIconUrl": "",
        "miniProgramTitle": "",
        "miniProgramPicMediaId": "",
        "miniProgramPicUrl": "",
        "miniProgramAppId": "",
        "miniProgramPage": "",
        "sort": 1
    ],
    "appName" : "SCRM",
    "creatorId" : 1212129981,
    "creatorName":"Me"
}

solution

helloList also has addAutoWelcomeRequests this place, because Java objects are an array, my writing is wrong, the correct way of writing should be

{
    "groupId": 12321321321,
    "taskName": "YourTaskName",
    "companyId": 12321312,
    "helloList": ["xxxxxxxx","testGroup"],
    "addAutoWelcomeRequests": [
        {
            "type": 1,
        "content": "hahha",
        "fileUrl": "http:/sssss",
        …………
        }
    ],
    "appName" : "xxx",
    "creatorId" : xxxx,
    "creatorName":"xxxxx"
}

this will be fine to be converted.

created at:07-30-2021
edited at: 06-04-2022: