genuinner opened a new issue, #16430:
URL: https://github.com/apache/dolphinscheduler/issues/16430

   ### 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
   
   When i try to parse json to complex class(like BaseHeartBeat.class), there 
will be a ClassCastException.
   That is because the JSONUtils.toMap(String json, Class<K> classK, Class<V> 
classV) uses TypeReference to parse json which cannot deal generic type 
correctly, we can use MapType instead.
   ```
   public void toGenericMap() {
           String json = 
"{\"beatHeart\":{\"processId\":18,\"host\":\"192.168.1.1\"}}";
   
           Map<String, BaseHeartBeat> models = JSONUtils.toMap(json, 
String.class, BaseHeartBeat.class);
           Assertions.assertEquals(18, models.get("beatHeart").getProcessId());
   }
   ```
   
   ### What you expected to happen
   
   no exceptin should be throw
   
   ### How to reproduce
   
   just parse the json to any custom class
   
   ### 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](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