Skip to main content

Module json

Module json 

Source
Expand description

JSON diagnostic output format.

This module provides machine-readable JSON output for diagnostics, compatible with IDE tooling and CI systems.

§Format

The output format is designed to be compatible with common conventions:

{
  "message": "error message",
  "code": "E0001",
  "severity": "error",
  "spans": [
    {
      "file": "src/main.hs",
      "line_start": 10,
      "line_end": 10,
      "column_start": 5,
      "column_end": 15,
      "is_primary": true,
      "label": "expected Int, found String"
    }
  ],
  "notes": ["consider using show"],
  "suggestions": [
    {
      "message": "try this",
      "replacement": "show x"
    }
  ]
}

Structs§

JsonDiagnostic
A diagnostic in JSON format.
JsonSpan
A source span in JSON format.
JsonSuggestion
A suggested fix in JSON format.

Enums§

JsonApplicability
Applicability in JSON format.
JsonSeverity
Severity level in JSON format.

Functions§

diagnostic_to_json
Convert a diagnostic to JSON format.
diagnostics_to_json
Convert multiple diagnostics to JSON format.
to_json_lines
Serialize diagnostics to a JSON string (compact, one per line).
to_json_string
Serialize diagnostics to a JSON string.