[Bug] JSONUtils Problem
Search before asking
- [x] I had searched in the issues and found no similar issues.
What happened
public static Map<String, String> toMap(String json) 该方法兼容性有问题,当我的http组件,请求Body 是
{
"applyId": "CA2024011800236476",
"bizType": "SX",
"customerName": "张三",
"decisionCode": "yqg_sx",
"featureSourceDataList": [{
"data": "{"dataId":"test","content":"test","status":"200"}",
"dataType": "TEST"
}],
"idNo": "201283199306196679",
"mobileNo": "18575307870",
"parallelSwitch": "NEW",
"params": {},
"computeTaskName": "TEST",
"productId": "PN00011507-0002",
"productNo": "PN00011507"}
这样的时候,由于featureSourceDataList value比较特殊,toMap 会失败跑出错误
json to map exception!
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.lang.String from Array value (token JsonToken.START_ARRAY)
What you expected to happen
我在本地测试的时候,发现存在该问题
How to reproduce
{ "applyId": "CA2024011800236476", "bizType": "SX", "customerName": "张三", "decisionCode": "yqg_sx", "featureSourceDataList": [{ "data": "{"dataId":"test","content":"test","status":"200"}", "dataType": "TEST" }], "idNo": "201283199306196679", "mobileNo": "18575307870", "parallelSwitch": "NEW", "params": {}, "computeTaskName": "TEST", "productId": "PN00011507-0002", "productNo": "PN00011507"},使用这段报文测试即可复现
Anything else
No response
Version
dev
Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Search before asking
- [x] I had searched in the issues and found no similar issues.
What happened
public static Map<String, String> toMap(String json) There is a problem with the compatibility of this method, when my http component, the request Body is
{
"applyId": "CA2024011800236476",
"bizType": "SX",
"customerName": "Zhang San",
"decisionCode": "yqg_sx",
"featureSourceDataList": [{
"data": "{"dataId":"test","content":"test","status":"200"}",
"dataType": "TEST"
}],
"idNo": "201283199306196679",
"mobileNo": "18575307870",
"parallelSwitch": "NEW",
"params": {},
"computeTaskName": "TEST",
"productId": "PN00011507-0002",
"productNo": "PN00011507"}
In this case, because featureSourceDataList value is special, toMap will fail and run an error
json to map exception!
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.lang.String from Array value (token JsonToken.START_ARRAY)
What you expected to happen
When I was testing locally, I found that there was this problem
How to reproduce
{ "applyId": "CA2024011800236476", "bizType": "SX", "customerName": "Zhang San", "decisionCode": "yqg_sx", "featureSourceDataList": [{ "data": "{"dataId":"test","content":"test","status":"200"}", "dataType": "TEST" }], "idNo": "201283199306196679", "mobileNo": "18575307870", "parallelSwitch": "NEW", "params": {}, "computeTaskName": "TEST", "productId": "PN00011507-0002", "productNo": "PN00011507"}, use this message to test and reproduce
Anything else
No response
Version
dev
Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
This is not a bug. The main reason is that your json is invalid.
"data": "{"dataId":"test","content":"test","status":"200"}"
should be
"data": "{\"dataId\":\"test\",\"content\":\"test\",\"status\":\"200\"}"
"data": "{"dataId":"test","content":"test","status":"200"}"
Yes, you're absolutely right, the example you provided is indeed like that. However, when I pasted the JSON into a GitHub issue, the escape characters were lost.
,您说的对,而且正如的您的描述,我的报问数据是这样的"data": "{\"dataId\":\"test\",\"content\":\"test\",\"status\":\"200\"}",在http组件间中
这个方法会将转义字符给去掉,从而导致报文被串改
Got it. Would you like to fix it?
BTW, Please using english to describe. @cyemars
I've assigned to you. Looking forward to your contribution.
Hi @cyemars Did you fix the issue ? If not, can I give it a try?
@SbloodyS can you assign this to me i will soon fix it