scanDiagnosticsToJsonString function

String scanDiagnosticsToJsonString(
  1. List<ScanDiagnostic> diagnostics, {
  2. Map<String, Object>? failOn,
})

Encodes diagnostics to a JSON string (pretty-printed).

When failOn is provided, a failOn object is included in the root to explain exit-code semantics to JSON consumers.

Implementation

String scanDiagnosticsToJsonString(
  List<ScanDiagnostic> diagnostics, {
  Map<String, Object>? failOn,
}) {
  return const JsonEncoder.withIndent(
    '  ',
  ).convert(scanDiagnosticsToJson(diagnostics, failOn: failOn));
}