encode static method
dynamic
encode(
- dynamic data
Implementation
static dynamic encode(dynamic data) {
if (data is LogicCommand) {
return data.toJson();
}
if (data is UpdateCommand) {
return data.toJson();
}
if (data is Map) {
var map = {};
data.forEach((key, value) {
map[key] = encode(value);
});
return map;
}
if (data is List) {
var list = [];
data.forEach((value) {
list.add(encode(value));
});
return list;
}
if (data is DateTime) {
return {'\$date': data.microsecondsSinceEpoch};
}
return data;
}