JsonRecordSerializer constructor

JsonRecordSerializer({
  1. int? indent,
})

Creates a JSON serializer with optional pretty-print indentation.

Null indent emits compact JSON Lines. A negative indent throws ArgumentError.

Implementation

factory JsonRecordSerializer({int? indent}) {
  if (indent != null && indent < 0) {
    throw ArgumentError.value(indent, 'indent', 'must be nonnegative');
  }
  return JsonRecordSerializer._(
    indent,
    JsonEncoder.withIndent(indent == null ? null : ' ' * indent),
  );
}