I'm accessing the API which have uppercase enum values, but I don't like them and so want to be able to deserialize them with case insensitive way.

This does not work:

enum Color {
	red,
	green,
	blue
}
	
struct Test {
	@byName Color color;
}

assert(deserializeJson!Test(Json(["color":Json("RED")])).color == Color.red);


I tried to implement custom policy, like this (there is not much documentation about it):

template UpperCasePolicy(S) {
	import std.conv, std.string : toLower, toUpper;

	S fromRepresentation(string value) {
		return value.toLower.to!S;
	}

	string toRepresentation(S value) {
		return to!string(value).toUpper;
	}
}
	
struct Test {
	@byName!UpperCasePolicy Color color;
}

But it ends up with the strange error: Got JSON of type string, expected int_, bigInt

I can't figure out what I'm doing wrong :(