Deserialization for enums of any type

Previously only enums of type int could be deserialized. This is now possible for any enum type.