JsonParser class
Converts loosely-typed JSON-decoded values (num/String/List/Map/etc.)
into strongly-typed Dart values, and detects a generic type parameter's
runtime shape via the is T trick used throughout this class.
Constructors
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
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
isDynamic<
T extends Object?> () → bool -
Whether T is
dynamic/Object?. -
isList<
T extends Object?> () → bool -
Whether T is
List<dynamic>. -
isListOfMapStringDynamic<
T extends Object?> () → bool -
Whether T is
List<Map<String, dynamic>>. -
isMap<
T extends Object?> () → bool -
Whether T is
Map<dynamic, dynamic>. -
isMapStringDynamic<
T extends Object?> () → bool -
Whether T is
Map<String, dynamic>. -
isString<
T extends Object?> () → bool -
Whether T is
String. -
valueAs<
T extends Object?> (Object? value, {bool? allowHex, StringEncoding? encoding, bool asBytes = false}) → T -
Central dispatcher: coerces
valueto whichever concrete type T is (num/String/List/Map/Set/etc.), by inspecting T's runtime shape. -
valueAsBigInt<
T extends BigInt?> (Object? value, {bool allowHex = false, bool? sign, bool allowDecimals = false}) → T -
Coerces
value(int/String/hex/decimal string) to a BigInt. -
valueAsBool<
T extends bool?> (Object? value) → T -
Coerces
value(bool or "true"/"false" string) to a bool. -
valueAsBytes<
T extends List< (int> ?>Object? value, {bool allowHex = true, StringEncoding? encoding, bool allowJson = false}) → T -
Coerces
valueto a byte list — accepts a raw byte List, a hex orencoding-decoded String, or (withallowJson) a JSON-encoded list/map. -
valueAsDouble<
T extends double?> (Object? value) → T -
Coerces
value(num/String) to a double. -
valueAsInt<
T extends int?> (Object? value, {bool allowHex = false, bool allowDouble = false}) → T -
Coerces
value(num/String/hex string) to an int. -
valueAsList<
T extends List?> (Object? value) → T -
Coerces
valueto whichever concreteList<...>shape T is. -
valueAsMap<
T extends Map?> (Object? value) → T -
Coerces
valueto aMap<String, dynamic>orMap<String, String>, matching whichever T actually is. -
valueAsNum<
T extends num?> (Object? value, {bool allowHex = false, bool allowDouble = false}) → T -
Coerces
value(num/String/hex string) to a num. -
valueAsSet<
T extends Set?> (Object? value) → T -
Coerces
valueto whichever concreteSet<...>shape T is. -
valueAsString<
T extends String?> (Object? value, {bool allowJson = false, bool allowHexEncoding = false, StringEncoding? bytesEncoding = StringEncoding.utf8}) → T -
Coerces
valueto a String — decodes byte lists, optionally JSON-encodes lists/maps. -
valueEnsureAsList<
T> (Object? value) → List< T> -
Casts
valuetoList<T>, converting each element if needed. -
valueEnsureAsMap<
KK, VV> (Object? value) → Map< KK, VV> -
Casts
valuetoMap<KK, VV>, rebuilding it if it isn't already one. -
valueEnsureAsSet<
T> (Object? value) → Set< T> -
Casts
valuetoSet<T>, rebuilding it if it isn't already one. -
valueTo<
T extends Object?, VV extends Object?> ({required Object? value, required T parse(VV v), bool? allowHex, StringEncoding? encoding, bool asBytes = false}) → T -
Coerces
valuetoVVvia valueAs, then appliesparseto build aT.