serialize static method

String serialize(
  1. Object? object, [
  2. JsonSerializerOptions? options
])

Serializes the given object into a JSON string using the provided options. Returns the serialized JSON string.

Implementation

static String serialize(Object? object, [JsonSerializerOptions? options]) {
  final opts = JsonSerializer.options.merge(options);

  return jsonEncode(object, toEncodable: (value) {
    final type = DartParser.parseType(value.runtimeType.toString());
    return encode(value, type, opts);
  });
}