JsonClass class abstract
Abstract class that other classes should extend to provide conversion to or from JSON.
- Implementers
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
listof dynamic objects given abuilderthat can build a single object. -
fromDynamicMap<
T> (dynamic map, JsonClassBuilder< T> builder) → Map<String, T> -
Helper function to create a
mapof string keys to dynamic objects given abuilderthat can build a single object. -
fromDynamicMapWithKey<
T> (dynamic map, JsonClassWithKeyBuilder< T> builder) → Map<String, T> -
Helper function to create a
mapof string keys to dynamic objects given abuilderthat 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
listof dynamic objects given abuilderthat can build a single object. -
maybeFromDynamicMap<
T> (dynamic map, JsonClassBuilder< T> builder) → Map<String, T> ? -
Helper function to create a
mapof string keys to dynamic objects given abuilderthat can build a single object. -
maybeFromDynamicMapWithKey<
T> (dynamic map, JsonClassWithKeyBuilder< T> builder) → Map<String, T> ? -
Helper function to create a
mapof string keys to dynamic objects given abuilderthat can build a single object with the key from the incoming map being passed to the builder. -
maybeParseBool(
dynamic value) → bool? -
Parses the dynamic
valueinto a bool. This will returntrueif and only if the value is... -
maybeParseDateTime(
dynamic value) → DateTime? -
Parses the given
valueinto a DateTime object. If thevaluecannot be parsed then null will be returned. -
maybeParseDouble(
dynamic value, [double? defaultValue]) → double? -
Parses the dynamic
valueinto a double. Thevaluemay be a String, int, or double. If thevaluecannot be successfully parsed into a double then thedefaultValuewill be returned. -
maybeParseDoubleList(
dynamic value) → List< double> ? -
Parses the dynamic
valueinto 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
valuemay be an int, double, or number encoded String. -
maybeParseDurationFromSeconds(
dynamic value) → Duration? -
Parses a duration from seconds. The
valuemay be an int, double, or number encoded String. -
maybeParseInt(
dynamic value) → int? -
Parses the dynamic
valueinto a int. The value may be a String, int, double. If thevaluecannot be successfully parsed into an int then [thedefaultValuewill be returned. -
maybeParseIntList(
dynamic value) → List< int> ? -
Parses the dynamic
valueinto 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
valuein to it's JSON decoded form. If thevaluecannot be decoded this will either return null. -
maybeParseUtcMillis(
dynamic value) → DateTime? -
Parses the given UTC Millis into a proper DateTime class. If the
valuecannot be processed then this will return null. -
maybeParseValue<
T> (dynamic input) → T? -
Attempts to parse the given
inputinto the typeT. This currently supports the following types: -
maybeToJsonList(
List< JsonClass> ? list) → List? -
Converts the given
listof 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
valueinto a bool. This will returntrueif and only if the value is... -
parseDateTime(
dynamic value) → DateTime -
Parses the given
valueinto a DateTime object. If thevaluecannot be parsed then null will be returned. -
parseDouble(
dynamic value) → double -
Parses the dynamic
valueinto a double. Thevaluemay be a String, int, or double. If thevaluecannot be successfully parsed into a double then null will be returned. -
parseDoubleList(
dynamic value) → List< double> -
Parses the dynamic
valueinto 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
valuemay be an int, double, or number encoded String. -
parseDurationFromSeconds(
dynamic value) → Duration -
Parses a duration from seconds. The
valuemay be an int, double, or number encoded String. -
parseInt(
dynamic value) → int -
Parses the dynamic
valueinto a int. The value may be a String, int, double. -
parseIntList(
dynamic value) → List< int> -
Parses the dynamic
valueinto 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
valuein to it's JSON decoded form. -
parseLevel(
dynamic value, [Level defaultLevel = Level.INFO]) → Level -
Parses the dynamic
valueinto aLevelsuitable for usage with the logging package. Thevalueis 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
inputinto the typeT. 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
removeEmptyCollectionstofalse. -
toJsonList(
List< JsonClass> list) → List -
Converts the given
listof JsonClass objects into JSON. If the given list is null` then null will be returned.