toJsonMap method
Map<String, dynamic> ?
toJsonMap({
- O? obj,
- JsonEncoder? jsonEncoder,
- bool duplicatedEntitiesAsID = false,
- bool? autoResetEntityCache,
override
Returns a JSON Map.
If the class implements toJson
calls it.
- If
obj
is not provided, uses object as instance.
Implementation
@override
Map<String, dynamic>? toJsonMap(
{O? obj,
JsonEncoder? jsonEncoder,
bool duplicatedEntitiesAsID = false,
bool? autoResetEntityCache}) {
obj ??= object;
if (obj == null) return null;
if (hasMethodToJson) {
var json = callMethodToJson(obj);
if (jsonEncoder != null) {
json = jsonEncoder.toJson(json,
duplicatedEntitiesAsID: duplicatedEntitiesAsID,
autoResetEntityCache: autoResetEntityCache);
}
if (json is Map) {
var map = json is Map<String, dynamic>
? json
: json.map((key, value) => MapEntry('$key', value));
return map;
}
}
return toJsonFromFields(
obj: obj,
jsonEncoder: jsonEncoder,
duplicatedEntitiesAsID: duplicatedEntitiesAsID,
autoResetEntityCache: autoResetEntityCache);
}