JsonClass class abstract

Abstract class that other classes should extend to provide conversion to or from JSON.

Constructors

JsonClass()
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Abstract function that concrete classes must implement. This must encode the internal data model to a JSON compatible representation.
toString() String
Returns the string encoded JSON representation for this class. This will remove all null values and empty collections from the returned string.
override

Operators

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

Static Methods

fromDynamicList<T>(Iterable list, JsonClassBuilder<T> builder) List<T>
Helper function to create a list of dynamic objects given a builder that can build a single object.
fromDynamicMap<T>(dynamic map, JsonClassBuilder<T> builder) Map<String, T>
Helper function to create a map of string keys to dynamic objects given a builder that can build a single object.
fromDynamicMapWithKey<T>(dynamic map, JsonClassWithKeyBuilder<T> builder) Map<String, T>
Helper function to create a map of string keys to dynamic objects given a builder that can build a single object with the key from the incoming map being passed to the builder.
maybeFromDynamicList<T>(Iterable? list, JsonClassBuilder<T> builder) List<T>?
Helper function to create a list of dynamic objects given a builder that can build a single object.
maybeFromDynamicMap<T>(dynamic map, JsonClassBuilder<T> builder) Map<String, T>?
Helper function to create a map of string keys to dynamic objects given a builder that can build a single object.
maybeFromDynamicMapWithKey<T>(dynamic map, JsonClassWithKeyBuilder<T> builder) Map<String, T>?
Helper function to create a map of string keys to dynamic objects given a builder that can build a single object with the key from the incoming map being passed to the builder.
maybeParseBool(dynamic value) bool?
Parses the dynamic value into a bool. This will return true if and only if the value is...
maybeParseDateTime(dynamic value) DateTime?
Parses the given value into a DateTime object. If the value cannot be parsed then null will be returned.
maybeParseDouble(dynamic value, [double? defaultValue]) double?
Parses the dynamic value into a double. The value may be a String, int, or double. If the value cannot be successfully parsed into a double then the defaultValue will be returned.
maybeParseDoubleList(dynamic value) List<double>?
Parses the dynamic value into a List of double values. The value may be null, in which case null will be returned, or it may be an array of any type, but each element in the array must be parsable into a valid double or an error will be thrown.
maybeParseDurationFromMillis(dynamic value) Duration?
Parses a duration from milliseconds. The value may be an int, double, or number encoded String.
maybeParseDurationFromSeconds(dynamic value) Duration?
Parses a duration from seconds. The value may be an int, double, or number encoded String.
maybeParseInt(dynamic value) int?
Parses the dynamic value into a int. The value may be a String, int, double. If the value cannot be successfully parsed into an int then [the defaultValue will be returned.
maybeParseIntList(dynamic value) List<int>?
Parses the dynamic value into a List of int values. The value may be null, in which case null will be returned, or it may be an array of any type, but each element in the array must be parsable into a valid int or an error will be thrown.
maybeParseJson(dynamic value) → dynamic
Parses the dynamic value in to it's JSON decoded form. If the value cannot be decoded this will either return null.
maybeParseUtcMillis(dynamic value) DateTime?
Parses the given UTC Millis into a proper DateTime class. If the value cannot be processed then this will return null.
maybeParseValue<T>(dynamic input) → T?
Attempts to parse the given input into the type T. This currently supports the following types:
maybeToJsonList(List<JsonClass>? list) List?
Converts the given list of JsonClass objects into JSON. If the given list is null` then null will be returned.
parseBool(dynamic value, {bool whenNull = false}) bool
Parses the dynamic value into a bool. This will return true if and only if the value is...
parseDateTime(dynamic value) DateTime
Parses the given value into a DateTime object. If the value cannot be parsed then null will be returned.
parseDouble(dynamic value) double
Parses the dynamic value into a double. The value may be a String, int, or double. If the value cannot be successfully parsed into a double then null will be returned.
parseDoubleList(dynamic value) List<double>
Parses the dynamic value into a List of double values. The value may be null, in which case null will be returned, or it may be an array of any type, but each element in the array must be parsable into a valid double or an error will be thrown.
parseDurationFromMillis(dynamic value) Duration
Parses a duration from milliseconds. The value may be an int, double, or number encoded String.
parseDurationFromSeconds(dynamic value) Duration
Parses a duration from seconds. The value may be an int, double, or number encoded String.
parseInt(dynamic value) int
Parses the dynamic value into a int. The value may be a String, int, double.
parseIntList(dynamic value) List<int>
Parses the dynamic value into a List of int values. The value may be null, in which case null will be returned, or it may be an array of any type, but each element in the array must be parsable into a valid int or an error will be thrown.
parseJson(dynamic value) → dynamic
Parses the dynamic value in to it's JSON decoded form.
parseLevel(dynamic value, [Level defaultLevel = Level.INFO]) → Level
Parses the dynamic value into a Level suitable for usage with the logging package. The value is case-insensitive accepted values are:
parseUtcMillis(dynamic value) DateTime
Parses the given UTC Millis into a proper DateTime class.
parseValue<T>(dynamic input) → T
Attempts to parse the given input into the type T. This currently supports the following types:
removeNull(dynamic input, [bool removeEmptyCollections = true]) → dynamic
Removes null values from the given input. This defaults to removing empty lists and maps. To override this default, set the optional removeEmptyCollections to false.
toJsonList(List<JsonClass> list) List
Converts the given list of JsonClass objects into JSON. If the given list is null` then null will be returned.