JsonObject<T extends JsonModel> class

A specialized JSON field for handling nested JsonModel objects.

JsonObject extends JsonField<T> to provide type-safe handling of nested model objects in JSON data. It automatically deserializes JSON objects into model instances and provides convenient access to nested fields using the [] and []= operators.

Key Features:

  • Automatic deserialization of JSON objects to model instances
  • Nested field access using [] and []= operators
  • Lazy instantiation: creates a new model instance if value is null
  • Type-safe operations with generic type parameter

Type Parameter:

  • T: The type of JsonModel this field holds (e.g., UserModel, AddressModel).

Usage Example:

final address = JsonObject<AddressModel>('address');
address.value = {
  'street': '123 Main St',
  'city': 'New York'
}; // Automatically deserializes to AddressModel

print(address['city']); // 'New York'
address['zipCode'] = '10001'; // Set nested field

See also:

Inheritance

Constructors

JsonObject(String fieldName)
Creates a new JsonObject field with the specified field name.

Properties

error ↔ String?
An error message associated with this field, if any.
getter/setter pairinherited
fieldName → String
The name of this field as it appears in JSON data.
finalinherited
hasError → bool
Returns true if this field has an error message.
no setterinherited
hashCode → int
Returns the hash code for this field.
no setterinherited
hasInformation → bool
Returns true if this field has an informational message.
no setterinherited
hasWarning → bool
Returns true if this field has a warning message.
no setterinherited
information ↔ String?
An informational message associated with this field, if any.
getter/setter pairinherited
isNotNull → bool
Returns true if the raw value of this field is not null.
no setterinherited
isNull → bool
Returns true if the raw value of this field is null.
no setterinherited
rawValue ↔ T?
The raw, unprocessed value stored in this field.
getter/setter pairinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value ↔ T
Returns the model object, creating a new instance if needed.
getter/setter pairoverride
warning ↔ String?
A warning message associated with this field, if any.
getter/setter pairinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>?
Serializes the nested model object to a JSON map.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
Determines whether this field is equal to another object.
inherited
operator [](String name) → dynamic
Retrieves the value of a nested field within the model object.
operator []=(String name, dynamic value) → void
Sets the value of a nested field within the model object.