Frontend  0.8.1
Loading...
Searching...
No Matches
json_helpers.dart File Reference

Functions

Object readAsList (Map json, String key)
 Reads [key] from [json] and normalizes it to a list.
Object readAsSingle (Map json, String key)
 Reads [key] from [json] only if the value is a map, otherwise returns null.
Object readNestedAsList (Map json, String key)
 Reads [key] from [json], applies [_unwrapMap], and normalizes to a list.
Object readWrappedAsList (Map json, String key)
 Unwraps a single-element array containing a single-key map into a list.
List< dynamic > _asList (Object? value)
 null[], [...][...], x[x]
Object _unwrapList (Object? value)
 [x]x, otherwise identity
Object _unwrapMap (Object? value)
 {"k": v}v, otherwise identity

Function Documentation

◆ _asList()

List< dynamic > _asList ( Object? value)

◆ _unwrapList()

Object _unwrapList ( Object? value)

◆ _unwrapMap()

Object _unwrapMap ( Object? value)

◆ readAsList()

Object readAsList ( Map json,
String key )

Applies [_asList] to handle both single objects and arrays.

◆ readAsSingle()

Object readAsSingle ( Map json,
String key )

◆ readNestedAsList()

Object readNestedAsList ( Map json,
String key )

Flattens {"key": [...]} down to the inner list.

◆ readWrappedAsList()

Object readWrappedAsList ( Map json,
String key )

Applies [_unwrapList], [_unwrapMap], and [_asList] in sequence to flatten structures like [{"key": [...]}] down to the inner list.