JsonSerializable class

An annotation used to specify a class to generate code for.

Annotations
  • @JsonSerializable(checked: true, disallowUnrecognizedKeys: true, fieldRename: FieldRename.snake)

Constructors

JsonSerializable({bool anyMap, bool checked, bool createFactory, bool createToJson, bool disallowUnrecognizedKeys, bool explicitToJson, FieldRename fieldRename, bool ignoreUnannotated, bool includeIfNull, bool nullable })
Creates a new JsonSerializable instance.
const
JsonSerializable.fromJson(Map<String, dynamic> json)
factory

Properties

anyMap → bool
If true, Map types are not assumed to be Map<String, dynamic> – which is the default type of Map instances return by JSON decode in dart:convert. [...]
final
checked → bool
If true, generated fromJson functions include extra checks to validate proper deserialization of types. [...]
final
createFactory → bool
If true (the default), a private, static _$ExampleFromJson method is created in the generated part file. [...]
final
createToJson → bool
If true (the default), A top-level function is created that you can reference from your class. [...]
final
disallowUnrecognizedKeys → bool
If false (the default), then the generated FromJson function will ignore unrecognized keys in the provided JSON Map. [...]
final
explicitToJson → bool
If true, generated toJson methods will explicitly call toJson on nested objects. [...]
final
fieldRename FieldRename
Defines the automatic naming strategy when converting class field names into JSON map keys. [...]
final
ignoreUnannotated → bool
When true, only fields annotated with JsonKey will have code generated. [...]
final
includeIfNull → bool
Whether the generator should include fields with null values in the serialized output. [...]
final
nullable → bool
When true (the default), null fields are handled gracefully when encoding to JSON and when decoding null and nonexistent values from JSON. [...]
final
hashCode → int
The hash code for this object.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

toJson() → Map<String, dynamic>
withDefaults() JsonSerializable
Returns a new JsonSerializable instance with fields equal to the corresponding values in this, if not null. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator.
inherited

Constants

defaults → const JsonSerializable
An instance of JsonSerializable with all fields set to their default values.
const JsonSerializable(anyMap: false, checked: false, createFactory: true, createToJson: true, disallowUnrecognizedKeys: false, explicitToJson: false, fieldRename: FieldRename.none, ignoreUnannotated:…