toJson method
Object?
toJson([
- O? obj,
- JsonEncoder? jsonEncoder,
- bool duplicatedEntitiesAsID = false,
- bool? autoResetEntityCache,
override
Returns a JSON.
If the class implements toJson
calls it.
- If
obj
is not provided, uses object as instance.
Implementation
@override
Object? toJson(
[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) {
return jsonEncoder.toJson(json,
duplicatedEntitiesAsID: duplicatedEntitiesAsID,
autoResetEntityCache: autoResetEntityCache);
} else {
return json;
}
}
return toJsonFromFields(
obj: obj,
jsonEncoder: jsonEncoder,
duplicatedEntitiesAsID: duplicatedEntitiesAsID,
autoResetEntityCache: autoResetEntityCache);
}