stringify static method
Implementation
static String stringify(Map<String, dynamic> map) {
String encodeValue(dynamic value) {
if (value == null) {
return 'null';
} else if (value is num || value is bool) {
return value.toString();
} else if (value is DateTime) {
// Always put quotes around ISO8601 string representation of DateTime
return '"${value.toLocal().toIso8601String()}"';
} else if (value is Map) {
return stringify(Map<String, dynamic>.from(value));
} else if (value is List) {
return '[${value.map((v) => encodeValue(v)).join(', ')}]';
} else if (value is Record) {
return Json.stringify(value.toJson());
} else {
// Strings or any other types, always return quoted
String str = value.toString().replaceAll('"', r'\"');
return '"$str"';
}
}
return '{${map.entries.map((e) => '"${e.key}": ${encodeValue(e.value)}').join(', ')}}';
}