A JSON consumer that takes a parsed JSON value and produces desired Haxe value out of it. A Consumer instance has to be passed to the Parser methods.

It has three type parameters:

Methods

addArrayElement (context:TArrayContext, parser:Parser):Void

Add an array element. This is called when parser is about to parse the next array element.

The context is the value returned by the consumeArray method. This method MUST call parser.parseValue ONCE with some Consumer instance and can use its return value to modify the context (e.g. push the value to the Array).

addObjectField (context:TObjectContext, name:String, parser:Parser):Void

Add an object field. This is called when parser is about to parse the next object field.

The context is the value returned by the consumeObject method. This method MUST call parser.parseValue ONCE with some Consumer instance and can use its return value to modify the context (e.g. store the value in an object field).

consumeArray ():TArrayContext

Start consuming the JSON array. This is called when parser encounters the [ symbol.

This method should return the "array context", which will be passed over to addArrayElement and finalizeArray while parsing the array.

consumeBool (b:Bool):TResult

Consume a JSON boolean and produce the result value.

consumeNull ():TResult

Consume a JSON null and produce the result value.

consumeNumber (n:String):TResult

Consume a JSON number and produce the result value.

Number is passed as a string, because JSON defines no restrictions about the number precision and one is free to parse it into any type (e.g. haxe.Int64).

consumeObject ():TObjectContext

Start consuming the JSON object. This is called when parser encounters the { symbol.

This method should return the "object context", which will be passed over to addObjectField and finalizeObject while parsing the object.

consumeString (s:String):TResult

Consume a JSON string and produce the result value.

finalizeArray (context:TArrayContext):TResult

Finalize the JSON array and produce the result value. This is called when parser encounters the ] symbol.

The context is the value returned by the consumeArray method.

finalizeObject (context:TObjectContext):TResult

Finalize the JSON object and produce the result value. This is called when parser encounters the } symbol.

The context is the value returned by the consumeObject method.