Reputation: 53
I'm getting a JSON Mapping exception when trying to construct a HashMap
. The map is keyed on an enum
The input looks like this:
{"someObject":{"myMap":{"1":"2"}}}
Problem is it treats the "1"
as a String
and complains that it's not a valid representation as it's not one of the values of the enum
.
Any idea how to fix this?
Upvotes: 1
Views: 1266
Reputation: 42834
Have you tried using the actual names of the enum
values instead of their ordinal values?
enum Direction {
NORTH,SOUTH,EAST,WEST;
}
and
{"someObject":{"myMap":{"NORTH":"2"}}}
Upvotes: 1