Skip to content

Conversation

@Ujwalsingh-190
Copy link

This PR fixes JSONUtils.toMap to support nested JSON and non-string values.

Previously the method parsed Map<String, String> which caused failures when JSON values were objects or arrays.

Now it parses Map<String, Object> and safely converts values to string format while maintaining backward compatibility.

Fixes #17389

@boring-cyborg
Copy link

boring-cyborg bot commented Jan 18, 2026

Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)

@SbloodyS SbloodyS changed the title Fix JSONUtils to support nested JSON objects [Fix-17389] Fix JSONUtils to support nested JSON objects Jan 19, 2026
@SbloodyS SbloodyS added bug Something isn't working first time contributor First-time contributor labels Jan 19, 2026
@SbloodyS SbloodyS added this to the 3.4.1 milestone Jan 19, 2026
*/
public static Map<String, String> toMap(String json) {
return parseObject(json, new TypeReference<Map<String, String>>() {
Map<String, Object> map = parseObject(json, new TypeReference<Map<String, Object>>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is used in many places, and this modification may cause more serious problems, you need to use parseObject at the upper layer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review and suggestion. I understand the concern about modifying this common utility method. I will revert this change and move the parsing logic to the upper layer where it is needed. I’ll update the PR accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working first time contributor First-time contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] JSONUtils Problem

3 participants