I am trying to use a json configuration file, where all fields are @:optional, so that users only need to supply values for keys that deviate from my defaults.
Many fields use @:enum abstracts, so I tried to @:default(ABSTRACT_VALUE) which didn't compile, complaining about unknown Identifier : ABSTRACT_VALUE.
I had to specify the full module name, to get it to compile - which of course looks a bit ugly (see https://github.com/HaxeCheckstyle/tokentree-formatter/blob/master/src/tokentreeformatter/config/IndentationConfig.hx).
I tried to break it down into a smaller testcase, it consists of two files (I used neko target):
package test;
import json2object.JsonParser;
class Main {
public static function main() {
var parser = new JsonParser<TestData>();
var data = parser.fromJson("{}", "test.json");
trace(data);
}
}
package test;
typedef TestData = {
@:default(VAL2) @:optional var test:TestEnum;
}
@:enum
abstract TestEnum(String) {
var VAL1 = "value1";
var VAL2 = "value2";
var VAL3 = "value3";
}
I am trying to use a json configuration file, where all fields are
@:optional
, so that users only need to supply values for keys that deviate from my defaults. Many fields use@:enum abstract
s, so I tried to@:default(ABSTRACT_VALUE)
which didn't compile, complaining aboutunknown Identifier : ABSTRACT_VALUE
. I had to specify the full module name, to get it to compile - which of course looks a bit ugly (see https://github.com/HaxeCheckstyle/tokentree-formatter/blob/master/src/tokentreeformatter/config/IndentationConfig.hx).I tried to break it down into a smaller testcase, it consists of two files (I used neko target):
Compiler (Haxe 3.4.7 and Haxe 4 preview 4) complains:
test/TestData.hx:4: characters 11-15 : Unknown identifier : VAL2