encodeObject function
Encodes object
as JSON, given options
.
This is the base level function, but consider using niceJson()
instead.
Implementation
String encodeObject(Object? object, JsonOptions options) => switch (object) {
String s => encodeString(s),
num n => encodeNumber(n),
List l => encodeList(l, options),
Map m => encodeMap(m, options),
MapEntry e => encodeMapEntry(e, options),
Enum e => encodeString(e.name),
bool b => '$b',
null => 'null',
_ => throw Exception('Nice JSON couldn\'t encode object: $object'),
};