serializeObject function

dynamic serializeObject(
  1. dynamic value
)

Transforms any Dart datum into a value acceptable to json.encode.

Implementation

serializeObject(value) {
  if (_isPrimitive(value)) {
    logger.info("Serializing primitive value: $value");
    return value;
  } else if (value is DateTime) {
    logger.info("Serializing this DateTime: $value");
    return value.toIso8601String();
  } else if (value is Iterable) {
    logger.info("Serializing this Iterable: $value");
    return value.map(serializeObject).toList();
  } else if (value is Map) {
    logger.info("Serializing this Map: $value");
    return serializeMap(value);
  } else
    return serializeObject(reflection.serialize(value, serializeObject));
}