dolphinscheduler icon indicating copy to clipboard operation
dolphinscheduler copied to clipboard

[Bug] JSONUtils Problem

Open cyemars opened this issue 4 months ago • 9 comments

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

cyemars avatar Jul 30 '25 09:07 cyemars

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

github-actions[bot] avatar Jul 30 '25 09:07 github-actions[bot]

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\"}"

SbloodyS avatar Jul 30 '25 10:07 SbloodyS

"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.

cyemars avatar Jul 31 '25 02:07 cyemars

,您说的对,而且正如的您的描述,我的报问数据是这样的"data": "{\"dataId\":\"test\",\"content\":\"test\",\"status\":\"200\"}",在http组件间中

Image这个方法会将转义字符给去掉,从而导致报文被串改

Image 修改后这样 Image

cyemars avatar Aug 01 '25 07:08 cyemars

Got it. Would you like to fix it?

BTW, Please using english to describe. @cyemars

SbloodyS avatar Aug 06 '25 01:08 SbloodyS

Got it. Would you like to fix it?

BTW, Please using english to describe. @cyemars

Sure

cyemars avatar Aug 07 '25 02:08 cyemars

I've assigned to you. Looking forward to your contribution.

SbloodyS avatar Aug 07 '25 03:08 SbloodyS

Hi @cyemars Did you fix the issue ? If not, can I give it a try?

kito4 avatar Oct 10 '25 16:10 kito4

@SbloodyS can you assign this to me i will soon fix it

namanONcode avatar Dec 04 '25 16:12 namanONcode