jsonLiteral function
dynamic
jsonLiteral(
- dynamic element
Implementation
jsonLiteral(element) {
if (element is MModel) {
return element.wrapped;
} else if (element is MLiteral) {
return element.value;
} else if (element is DateTime) {
return element.toUtc().toIso8601String();
} else if (element is Uri) {
return element.toString();
} else if (element is TimeZone) {
return element.abbreviation;
} else if (element is Location) {
return element.name;
} else if (element is double) {
return element;
} else if (element is Duration) {
return "$element";
} else if (element is TimeSpan) {
return "$element";
} else if (element is bool) {
return element;
} else if (element is int) {
return element;
} else if (element is String) {
return element;
} else if (element is Iterable) {
return element.map((item) => jsonLiteral(item)).toList();
} else if (element is Map) {
return element
.map((key, value) => MapEntry(jsonLiteral(key), jsonLiteral(value)));
} else {
return element;
}
}