encode static method

String encode(
  1. Object? o, {
  2. bool pretty = false,
  3. JsonFieldMatcher? maskField,
  4. String maskText = '***',
  5. JsonFieldMatcher? removeField,
  6. bool removeNullFields = false,
  7. ToEncodableJsonProvider? toEncodableProvider,
  8. ToEncodable? toEncodable,
  9. EntityHandlerProvider? entityHandlerProvider,
  10. EntityCache? entityCache,
  11. bool? autoResetEntityCache,
})

Transforms o to an encoded JSON.

  • If pretty is true generates a pretty JSON, with indentation and line break.
  • maskField is the mask function. See toJson.
  • toEncodable converts a not encodable Object to a encodable JSON collection/data. See dart_convert.JsonEncoder.

Implementation

static String encode(Object? o,
    {bool pretty = false,
    JsonFieldMatcher? maskField,
    String maskText = '***',
    JsonFieldMatcher? removeField,
    bool removeNullFields = false,
    ToEncodableJsonProvider? toEncodableProvider,
    ToEncodable? toEncodable,
    EntityHandlerProvider? entityHandlerProvider,
    EntityCache? entityCache,
    bool? autoResetEntityCache}) {
  var jsonEncoder = _buildJsonEncoder(
      maskField,
      maskText,
      removeField,
      removeNullFields,
      toEncodableProvider,
      toEncodable,
      entityHandlerProvider,
      entityCache);

  return jsonEncoder.encode(o,
      pretty: pretty, autoResetEntityCache: autoResetEntityCache);
}