JsonProperty class
JsonProperty is used as metadata, for annotation of individual class fields to fine tune & configure Json property level.
- Annotations
-
- @Target({TargetKind.field, TargetKind.method, TargetKind.parameter, TargetKind.getter, TargetKind.setter})
Constructors
- JsonProperty({dynamic scheme, dynamic name, bool? required, bool? notNull, bool? ignore, bool? inject, bool? flatten, String? requiredMessage, String? notNullMessage, bool? ignoreForSerialization, bool? ignoreForDeserialization, bool? ignoreIfNull, bool? ignoreIfDefault, ICustomConverter? converter, dynamic defaultValue, Map? converterParams})
-
const
Properties
- converter → ICustomConverter?
-
Declares custom converter instance, to be used for annotated field
serialization / deserialization
final
- converterParams → Map?
-
Map of parameters to be passed to the converter instance
final
- defaultValue → dynamic
-
Final field default value
final
- flatten → bool?
-
Declares annotated field to be flattened and merged with the host object
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- ignore → bool?
-
Declares annotated field as ignored so it will be excluded from
serialization / deserialization process
final
- ignoreForDeserialization → bool?
-
Declares annotated field as excluded from deserialization process
final
- ignoreForSerialization → bool?
-
Declares annotated field as excluded from serialization process
final
- ignoreIfDefault → bool?
-
Declares annotated field as ignored if it's value is JsonProperty.defaultValue so it
will be excluded from serialization process
final
- ignoreIfNull → bool?
-
Declares annotated field as ignored if it's value is null so it
will be excluded from serialization process
final
- inject → bool?
-
Declares annotated field to be directly injected from DeserializationOptions.injectableValues
during deserialization process
final
- name → dynamic
-
Defines RFC 6901 JSON
pointer
Denotes the json property name/path/aliases to be used for mapping to the annotated field Example: name: 'foo' name: 'bar' name: 'foo/bar/baz' name: '../foo' name: '..' name:'foo', 'bar', 'baz'
'foo' - primary, 'bar', 'baz' - aliasesfinal - notNull → bool?
-
Declares annotated field as NOT NULL for serialization / deserialization process
i.e needs to be present in incoming JSON payload object as not NULL value
Optional custom message notNullMessage could be provided as well
Strict obligation
If set to
true
states of required, ignore, ignoreForDeserialization, ignoreForSerialization, ignoreIfNull, Json.ignoreNullMembers has no meaning.final - notNullMessage → String?
-
Defines an optional message to be thrown as an explanation to why is
this field needs to be not NULL in incoming JSON payload object
If this message is provided it's treated as if notNull is set to
true
final - required → bool?
-
Declares annotated field as required for serialization / deserialization process
i.e needs to be present explicitly in incoming JSON payload object
Optional custom message requiredMessage could be provided as well
Mild obligation
If set to
true
states of ignore, ignoreForDeserialization, ignoreForSerialization, ignoreIfNull, Json.ignoreNullMembers has no meaning.final - requiredMessage → String?
-
Defines an optional message to be thrown as an explanation to why is
this field needs to be provided in incoming JSON payload object
If this message is provided it's treated as if required is set to
true
final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scheme → dynamic
-
Scheme marker to associate this meta information with particular mapping scheme
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getAliases(
JsonProperty? jsonProperty) → List< String> ? -
getPrimaryName(
JsonProperty? jsonProperty) → String? -
hasParentReference(
JsonProperty? jsonProperty) → bool - name is referencing Parent object itself OR it's fields, by default this means that ignoreForSerialization is treated as true
-
isDefaultValue(
JsonProperty? jsonProperty, dynamic value) → bool -
isNotNull(
JsonProperty? jsonProperty) → bool -
isRequired(
JsonProperty? jsonProperty) → bool
Constants
- parentReference → const String