const mixinafJson::Json

afJson::Json

@Js

(Service) - A one-stop shop for all your JSON mapping needs!

The methods in this service may be summarised as follows:

JSON Methods

converter

Source

abstract EntityConverter converter()

Returns the underlying EntityConverter instance.

fromEntity

Source

abstract Obj? fromEntity(Obj? entity, Type? entityType := null)

Converts the given entity instance to its jsonObj representation.

If entityType is null it defaults to entity.typeof().

inspectors

Source

abstract JsonTypeInspectors inspectors()

Returns the underlying JsonTypeInspectors instance.

jsonReader

Source

abstract JsonReader jsonReader()

Returns the underlying JsonReader instance.

jsonWriter

Source

abstract JsonWriter jsonWriter()

Returns the underlying JsonWriter instance.

make

Source

static new make(JsonTypeInspectors? inspectors := null, JsonReader? reader := null, JsonWriter? writer := null)

Creates a new Json instance with the given inspectors.

readJson

Source

abstract Obj? readJson(Str? json, Type? entityType := null)

Reads the the given JSON and (optionally) converts it to a Fantom entity instance.

The given JSON is read into a jsonObj. Should entityType not be null then the jsonObj is converted to a Fantom entity.

readJsonAsList

Source

abstract Obj?[]? readJsonAsList(Str? json)

Translates the given JSON to its Fantom List representation.

Convenience for (Obj?[]?) readJson(json, null)

readJsonAsMap

Source

abstract [Str:Obj?]? readJsonAsMap(Str? json)

Translates the given JSON to its Fantom Map representation.

Convenience for ([Str:Obj?]?) readJson(json, null)

toEntity

Source

abstract Obj? toEntity(Obj? jsonObj, Type entityType)

Converts the given jsonObj to a Fantom entity instance.

writeJson

Source

abstract Str writeJson(Obj? obj, Type? entityType := null, Obj? prettyPrintOptions := null)

Converts the given obj to JSON.

If entityType is not null then the given obj is taken to be an entity and is first converted to an jsonObj. The jsonObj is then written out to JSON.

prettyPrintOptions may be either a PrettyPrintOptions instance, or just true to enable pretty printing with defaults.