我通过postman测试java接口,报错如下:org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unexpected character ('{' (code 123)): was expecting double-quote to start field name; nested exception is com.fasterxml.jackson.core.JsonParseException: Unexpected character ('{' (code 123)): was expecting double-quote to start field name at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 2, column: 6];我的请求参数json:{ { "unitTypeKey": "9716191B-FFD4-4346-9031-3249E8A8F53D", "unitAssoKey": "82D40DBB-4203-4381-B810-091E2C06E0FA", "srcEntityId": "MD_ORG", "srcEntityVersion": "默认版本", "srcOrgCode": "LNSYBMHZ37", "tarEntityId": "MD_ORG", "tarEntityVersion": "默认版本", "tarOrgCode": "LNSYBMHZ37", "directChild": "1", "isImport": "0" }, { "success": true, "data": { "matchedSet": [ { "srcUnitKey": "LNSYBMHZ37", "tarUnitKey": "LNSYBMHZ37", "actionKey": "SKIP", "readOnly": false, "span": 0 }, { "srcUnitKey": "LNSYBMJS97", "tarUnitKey": "LNSYBMJS97", "actionKey": "SKIP", "readOnly": false, "span": 1 }, { "srcUnitKey": "LNSYQXHZ57", "tarUnitKey": "LNSYQXHZ57", "actionKey": "SKIP", "readOnly": false, "span": 1 } ], "delSet": [], "addedSet": [] }, "error": null } };可以帮我分析是什么问题导致的吗?
时间: 2023-07-03 07:18:45 浏览: 219
根据报错信息和你提供的请求参数,可以看出是请求参数的格式问题导致的。
错误提示中提到了 "Unexpected character ('{' (code 123)): was expecting double-quote to start field name" ,这意味着在请求参数的某一行中,出现了一个不应该出现的字符 '{' ,而解析器期望在这个位置看到一个双引号 " ,用来标识该行的字段名。
根据你提供的请求参数可以看出,你的请求参数是一个无效的 JSON 格式,因为它包含了两个顶级对象,而一个 JSON 格式的字符串中应该只有一个顶级对象。因此,需要将这两个顶级对象合并成一个对象,才能正确地解析请求参数。
请尝试修改请求参数为以下格式:
```
{
"unitTypeKey": "9716191B-FFD4-4346-9031-3249E8A8F53D",
"unitAssoKey": "82D40DBB-4203-4381-B810-091E2C06E0FA",
"srcEntityId": "MD_ORG",
"srcEntityVersion": "默认版本",
"srcOrgCode": "LNSYBMHZ37",
"tarEntityId": "MD_ORG",
"tarEntityVersion": "默认版本",
"tarOrgCode": "LNSYBMHZ37",
"directChild": "1",
"isImport": "0",
"result": {
"success": true,
"data": {
"matchedSet": [
{
"srcUnitKey": "LNSYBMHZ37",
"tarUnitKey": "LNSYBMHZ37",
"actionKey": "SKIP",
"readOnly": false,
"span": 0
},
{
"srcUnitKey": "LNSYBMJS97",
"tarUnitKey": "LNSYBMJS97",
"actionKey": "SKIP",
"readOnly": false,
"span": 1
},
{
"srcUnitKey": "LNSYQXHZ57",
"tarUnitKey": "LNSYQXHZ57",
"actionKey": "SKIP",
"readOnly": false,
"span": 1
}
],
"delSet": [],
"addedSet": []
},
"error": null
}
}
```
注意,这是一个有效的 JSON 格式,它只包含一个顶级对象,并且将原来两个顶级对象合并成了一个对象,同时将第二个对象的内容包裹在了一个名为 "result" 的字段中。这样,解析器就可以正确地解析请求参数了。
阅读全文