elnabo / json2object

Type safe Haxe/JSON (de)serializer
MIT License
66 stars 17 forks source link

Cannot parse enum with `value` as argument name #32

Closed kLabz closed 6 years ago

kLabz commented 6 years ago

Considering the following enum:

enum Enum1 {
    EnumValue1(value:String);
}

I cannot parse a value for Enum1.EnumValue1 because of the argument name being "value". If I change it to any (well, maybe not any, but "v" works, for instance) other name, it works.

var writer = new JsonWriter<Enum1>();
var json:String = writer.write(EnumValue1("test"));
trace(json); // {"EnumValue1": {"value": "test"}}

var parser = new JsonParser<Enum1>();
parser.fromJson(json, '');
trace(parser.errors); // []
trace(parser.value); // null
elnabo commented 6 years ago

Thanks for finding and fixing this issue.