Problem Description
When debugging the interface today, I encountered a problem. There is a json body parameter of post request,
Then there are only two attributes in vo, id and a collection.
Then when using apifox to debug the interface, it is found that the json parsing is abnormal:
操作失败,JSON parse error: Cannot deserialize value of type `java.util.ArrayList<org.jeecg.file.entity.SysConfigFile>` from Object value (token `JsonToken.START_OBJECT`);
Through the prompt information, it can be found that the parsing is not possible because the json structure is incorrect.
error demonstration
I originally passed it like this, and it will report an error:
{
"id": "403",
"x": {
"serialVersionUID": 1,
"id": 1,
"fileCode": "demoData",
"fileName": "demoData",
"fileNum": 1,
"fileSize": "demoData",
"fileCategoryDic": 1,
"fileTypeDic": 1,
"allowType": "demoData",
"izRequired": 1,
"fileDesc": "demoData",
"templateUrl": "demoData",
"handleUrl": "demoData",
"delFlag": 1,
"createBy": "demoData",
"createTime": "2023-05-09 09:45:36",
"updateBy": "demoData",
"updateTime": "2023-05-09 09:45:36",
"remark": "demoData",
"tenantId": "demoData",
"flag": true,
"quyang": "demoData"
}
}
Demonstrate correctly
A layer of array should be added to the list so that it can be parsed normally
{
"id": "403",
"sysConfigFiles": [{
"serialVersionUID": 1,
"id": 1,
"fileCode": "demoData",
"fileName": "demoData",
"fileNum": 1,
"fileSize": "demoData",
"fileCategoryDic": 1,
"fileTypeDic": 1,
"allowType": "demoData",
"izRequired": 1,
"fileDesc": "demoData",
"templateUrl": "demoData",
"handleUrl": "demoData",
"delFlag": 1,
"createBy": "demoData",
"createTime": "2023-05-09 09:45:36",
"updateBy": "demoData",
"updateTime": "2023-05-09 09:45:36",
"remark": "demoData",
"tenantId": "demoData",
"flag": true,
"quyang": "demoData"
}]
}
extension, multiple collection elements
If there are multiple collections, you can use them directly and divide them, for example:
{
"id": "403",
"sysConfigFiles": [{
"serialVersionUID": 1,
"id": 1,
"fileCode": "demoData",
"fileName": "demoData",
"fileNum": 1,
"fileSize": "demoData",
"fileCategoryDic": 1,
"fileTypeDic": 1,
"allowType": "demoData",
"izRequired": 1,
"fileDesc": "demoData",
"templateUrl": "demoData",
"handleUrl": "demoData",
"delFlag": 1,
"createBy": "demoData",
"createTime": "2023-05-09 09:45:36",
"updateBy": "demoData",
"updateTime": "2023-05-09 09:45:36",
"remark": "demoData",
"tenantId": "demoData",
"flag": true,
"quyang": "demoData"
},{
"serialVersionUID": 1,
"id": 1,
"fileCode": "demoData",
"fileName": "demoData",
"fileNum": 1,
"fileSize": "demoData",
"fileCategoryDic": 1,
"fileTypeDic": 1,
"allowType": "demoData",
"izRequired": 1,
"fileDesc": "demoData",
"templateUrl": "demoData",
"handleUrl": "demoData",
"delFlag": 1,
"createBy": "demoData",
"createTime": "2023-05-09 09:45:36",
"updateBy": "demoData",
"updateTime": "2023-05-09 09:45:36",
"remark": "demoData",
"tenantId": "demoData",
"flag": true,
"quyang": "demoData"
}
]
}