ExtJSONHelper<K, V> extension

Typed field lookup/coercion helpers for JSON-decoded maps.

on

Methods

ensureKeyExists(K key) → void

Available on Map<K, V>, provided by the ExtJSONHelper extension

Throws if key isn't present in this map.
hasValue(K key) → bool

Available on Map<K, V>, provided by the ExtJSONHelper extension

Whether key is present and its value isn't null.
oneOf<E, T>({required List<K> keys, required E parse(K key, T e)}) → E

Available on Map<K, V>, provided by the ExtJSONHelper extension

Tries each of keys in order, returning the first one present (parsed via parse).
valueAs<T extends Object?>(K key, {bool? allowHex, StringEncoding? encoding, bool asBytes = false, T onMissing()?, bool normalizeKeyLookup = false, T onError(BuError err)?}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to whichever concrete type T is.
valueAsBigInt<T extends BigInt?>(K key, {bool allowHex = false, T onError(BuError err)?, T onMissing()?, bool? sign, bool allowDecimals = false, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to a BigInt.
valueAsBool<T extends bool?>(K key, {T onError(BuError err)?, T onMissing()?, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to a bool.
valueAsBytes<T extends List<int>?>(K key, {bool allowHex = true, StringEncoding? encoding, bool allowJson = false, T onMissing()?, bool normalizeKeyLookup = false, T onError(BuError err)?}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to bytes.
valueAsDouble<T extends double?>(K key, {T onError(BuError err)?, T onMissing()?, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to a double.
valueAsInt<T extends int?>(K key, {bool allowHex = false, bool allowDouble = false, T onError(BuError err)?, T onMissing()?, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to an int.
valueAsList<T extends List?>(K key, {T onError(BuError err)?, T onMissing()?, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to a List.
valueAsMap<T extends Map?>(K key, {T onError(BuError err)?, T onMissing()?, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to a Map.
valueAsNum<T extends num?>(K key, {bool allowHex = false, bool allowDouble = false, T onError(BuError err)?, T onMissing()?, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to a num.
valueAsSet<T extends Set?>(K key, {T onError(BuError err)?, T onMissing()?, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to a Set.
valueAsString<T extends String?>(K key, {T onError(BuError err)?, T onMissing()?, bool allowJson = false, bool allowHexEncoding = false, StringEncoding? bytesEncoding = StringEncoding.utf8, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and coerces it to a String.
valueEnsureAsList<T>(K key, {List<T> onError(BuError err)?, List<T> onMissing()?, bool normalizeKeyLookup = false}) → List<T>

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and casts it to List<T>.
valueEnsureAsMap<KK, VV>(K key, {Map<KK, VV> onError(BuError err)?, Map<KK, VV> onMissing()?, bool normalizeKeyLookup = false}) → Map<KK, VV>

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and casts it to Map<KK, VV>.
valueEnsureAsSet<T>(K key, {Set<T> onError(BuError err)?, Set<T> onMissing()?, bool normalizeKeyLookup = false}) → Set<T>

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key and casts it to Set<T>.
valueTo<T extends Object?, VV extends Object?>({required K key, required T parse(VV v), bool? allowHex, StringEncoding? encoding, bool asBytes = false, T onMissing()?, T onError(BuError err)?, bool normalizeKeyLookup = false}) → T

Available on Map<K, V>, provided by the ExtJSONHelper extension

Reads key, coerces it to VV, then applies parse to build a T.