json2object has an annotation @:jcustomparse which allows for mutation of parsed values.
It also allows for validation, since throwing an error in this function will cause the issue to be properly caught.
Parsing will fail and parser.errors will contain the thrown exception.
Functions must be of the signature (hxjsonast.Json, String) -> T, where the String is the property name and T is the type of the property.
Static methods
staticdynamicValue(json:Json, name:String):Dynamic
Parser which outputs a Dynamic value, either a object or something else.
Parameters:
json | |
|---|---|
name |
Returns:
The value of the property.
staticeitherFloatOrFloats(json:Json, name:String):Null<Either<Float, Array<Float>>>
Parser which outputs a Either<Float, Array<Float>>.
staticeitherLegacyNoteData(json:Json, name:String):Either<Array<LegacyNoteSection>, LegacyNoteData>
Parser which outputs a Either<Array<LegacyNoteSection>, LegacyNoteData>.
Used by the FNF legacy JSON importer.
staticeitherLegacyScrollSpeeds(json:Json, name:String):Either<Float, LegacyScrollSpeeds>
Parser which outputs a Either<Float, LegacyScrollSpeeds>.
Used by the FNF legacy JSON importer.
staticsemverVersion(json:Json, name:String):Version
@:jcustomparse(funkin.data.DataParse.semverVersion)
Parameters:
json | Contains the |
|---|---|
name | The name of the property. |
Returns:
The value of the property as a thx.semver.Version.
staticsemverVersionRule(json:Json, name:String):VersionRule
@:jcustomparse(funkin.data.DataParse.semverVersionRule)
Parameters:
json | Contains the |
|---|---|
name | The name of the property. |
Returns:
The value of the property as a thx.semver.VersionRule.
staticstringNotEmpty(json:Json, name:String):String
@:jcustomparse(funkin.data.DataParse.stringNotEmpty)
Parameters:
json | Contains the |
|---|---|
name | The name of the property. |
Returns:
The string value.
Throws:
Error | If the property is not a string or is empty. |
|---|