toJsonFromFields method

Map<String, dynamic> toJsonFromFields({
  1. O? obj,
  2. JsonEncoder? jsonEncoder,
  3. bool duplicatedEntitiesAsID = false,
  4. bool? autoResetEntityCache,
})

Returns a JSON Map from fieldsNames, calling getField for each one.

  • If obj is not provided, uses object as instance.

Implementation

Map<String, dynamic> toJsonFromFields(
    {O? obj,
    JsonEncoder? jsonEncoder,
    bool duplicatedEntitiesAsID = false,
    bool? autoResetEntityCache}) {
  obj ??= object;
  if (obj == null) {
    throw StateError("Null object!");
  }

  var map = _toMapFromFieldsImpl(obj);

  jsonEncoder ??= JsonEncoder.defaultEncoder;
  return jsonEncoder.toJson(map,
      duplicatedEntitiesAsID: duplicatedEntitiesAsID,
      autoResetEntityCache: autoResetEntityCache);
}