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:

- converter
abstract EntityConverter converter()Returns the underlying
EntityConverterinstance.- fromEntity
abstract Obj? fromEntity(Obj? entity, Type? entityType := null)Converts the given entity instance to its
jsonObjrepresentation.If
entityTypeisnullit defaults toentity.typeof().- inspectors
abstract JsonTypeInspectors inspectors()Returns the underlying
JsonTypeInspectorsinstance.- jsonReader
abstract JsonReader jsonReader()Returns the underlying
JsonReaderinstance.- jsonWriter
abstract JsonWriter jsonWriter()Returns the underlying
JsonWriterinstance.- make
static new make(JsonTypeInspectors? inspectors := null, JsonReader? reader := null, JsonWriter? writer := null)Creates a new
Jsoninstance with the given inspectors.- readJson
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. ShouldentityTypenot be null then thejsonObjis converted to a Fantom entity.- readJsonAsList
abstract Obj?[]? readJsonAsList(Str? json)Translates the given JSON to its Fantom List representation.
Convenience for
(Obj?[]?) readJson(json, null)- readJsonAsMap
abstract [Str:Obj?]? readJsonAsMap(Str? json)Translates the given JSON to its Fantom Map representation.
Convenience for
([Str:Obj?]?) readJson(json, null)- toEntity
abstract Obj? toEntity(Obj? jsonObj, Type entityType)Converts the given
jsonObjto a Fantom entity instance.- writeJson
abstract Str writeJson(Obj? obj, Type? entityType := null, Obj? prettyPrintOptions := null)Converts the given obj to JSON.
If
entityTypeis not null then the givenobjis taken to be an entity and is first converted to anjsonObj. ThejsonObjis then written out to JSON.prettyPrintOptionsmay be either aPrettyPrintOptionsinstance, or justtrueto enable pretty printing with defaults.