pub fn to_json(
file: &str,
output: Option<&str>,
metadata: bool,
pretty: bool,
) -> Result<(), CliError>Expand description
Convert a HEDL file to JSON format.
Parses a HEDL file and converts it to JSON, with options for metadata inclusion and pretty-printing.
§Arguments
file- Path to the HEDL file to convertoutput- Optional output file path. IfNone, writes to stdoutmetadata- Iftrue, includes HEDL-specific metadata in the JSON outputpretty- Iftrue, pretty-prints the JSON with indentation
§Returns
Returns Ok(()) on success.
§Errors
Returns Err if:
- The file cannot be read
- The file contains syntax errors
- JSON conversion fails
- Output writing fails
§Examples
use hedl_cli::commands::to_json;
// Convert to compact JSON on stdout
to_json("data.hedl", None, false, false)?;
// Convert to pretty JSON with metadata
to_json("data.hedl", Some("output.json"), true, true)?;