aCodingAddict opened a new issue #6606:
URL: https://github.com/apache/dolphinscheduler/issues/6606


   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   in JSONUtils:
   `
   public static String getNodeString(String json, String nodeName) {
       try {
           JsonNode rootNode = objectMapper.readTree(json);
           return rootNode.has(nodeName) ? rootNode.get(nodeName).toString() : 
"";
       } catch (IOException e) {
           return "";
       }
   }
   `
   
   If the field value is a string, the result will be quoted.
   
   So far it's just "localParams" using this function,
   I think, JsonNodeType judgment is missing from JSONUtils#getNodeString,
   String type can consider using JsonNode#asText instead of JsonNode#toString.
   
   
   ### What you expected to happen
   
   A value of type string is changed during access
   
   ### How to reproduce
   
   HashMap<String, Object> map = new HashMap<>();
   map.put("localParams", "123");
   map.put("test", 123);
   
   
   // {"test":123,"localParams":"123"}
   String json = JSONUtils.toJsonString(map);
   
   
   String localParams = JSONUtils.getNodeString(json, "localParams");
   System.out.println(localParams);  //  "123"
   
   System.out.println("123".equals(localParams));   // false
   
   String localParams1 = 
objectMapper.readTree(json).get("localParams").asText();
   System.out.println("123".equals(localParams1));  // true
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to