Json class abstract

A safe json model for wrapping json values

Implementers
Annotations
  • @immutable

Constructors

Json.boolean(bool value)
const
factory
Json.fromJson(Object? value)
Creates a Json from a valid Json value. throws Exception if value could not be coerced into a Json
factory
Json.list(List<Json> value)
const
factory
Json.map(Map<String, Json> value)
const
factory
Json.none()
const
factory
Json.number(num value)
const
factory
Json.str(String value)
const
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value Object?
The inner value, may contain Json objects in maps or lists
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson({bool shallow = false}) Object?
Returns a serializable Json value. if shallow, it will not serialize inner Json values
toJsonShallow() Object?
Returns the inner json value
toString() String
A string representation of this object.
inherited
when<T>({required T map(Map<String, Json>), required T list(List<Json>), required T number(num), required T boolean(bool), required T str(String), required T none(Null)}) → T
Executes the given callback when [this.value is of the type parameter.

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

graphQLType GraphQLJsonType
The GraphQLType associated with Json
no setter

Static Methods

fromJsonChecked(Object? value, {String? getter, bool isRoot = true}) → Result<Json, String>
Creates a Json from a valid Json value. Similar to fromJson but does not throw when value could not be coerced into a Json, it returns an error message instead

Constants

null_ → const JsonNone
A null Json value