-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Labels
wontfixThis will not be worked onThis will not be worked on
Description
Search before asking
- I had searched in the issues 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 classK, Class 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?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
wontfixThis will not be worked onThis will not be worked on