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

Functions

Object readAsList (Map json, String key)
 Normalizes a JSON value that may be a single object or a list into a list.
Object readAsSingle (Map json, String key)
 Returns the value only if it's a map, otherwise null.
Object readNestedAsList (Map json, String key)
 Flattens a single-key wrapper object into a list.

Function Documentation

◆ readAsList()

Object readAsList ( Map json,
String key )

XML-to-JSON conversions often collapse single-element arrays into plain objects. This helper ensures the value is always a list for consistent deserialization.

◆ readAsSingle()

Object readAsSingle ( Map json,
String key )

Some fields are either an object or an empty list in the JSON. This helper treats an empty list (or any non-map value) as null.

◆ readNestedAsList()

Object readNestedAsList ( Map json,
String key )

For JSON structures like "protocols": { "protocol": [...] }, this unwraps the single inner key and applies [readAsList] normalization.