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.
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? 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.
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? defaultValue]) Duration?
Parses a duration from milliseconds. The value may be an int, double, or number encoded String. If the value cannot be processed into a duration then this will return the defaultValue.
parseDurationFromSeconds(dynamic value, [Duration? defaultValue]) Duration?
Parses a duration from seconds. The value may be an int, double, or number encoded String. If the value cannot be processed into a duration then this will return the defaultValue.
parseInt(dynamic value, [int? defaultValue]) 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.
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 defaultValue]) → dynamic
Parses the dynamic value in to it's JSON decoded form. If the value cannot be decoded this will either return the defaultValue, if not null, or return the value that was passed in if defaultValue is null.
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, [int? defaultValue]) DateTime?
Parses the given UTC Millis into a proper DateTime class. If the value cannot be processed then this will return the defaultValue or null if there is no provided defaultValue.
parseValue<T>(dynamic input) → dynamic
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.