Skip to main content

from_json

Function from_json 

Source
pub fn from_json(file: &str, output: Option<&str>) -> Result<(), CliError>
Expand description

Convert a JSON file to HEDL format.

Parses a JSON file and converts it to canonical HEDL format.

§Arguments

  • file - Path to the JSON file to convert
  • output - Optional output file path. If None, writes to stdout

§Returns

Returns Ok(()) on success.

§Errors

Returns Err if:

  • The file cannot be read
  • The JSON is malformed
  • JSON-to-HEDL conversion fails
  • HEDL canonicalization fails
  • Output writing fails

§Examples

use hedl_cli::commands::from_json;

// Convert JSON to HEDL on stdout
from_json("data.json", None)?;

// Convert JSON to HEDL file
from_json("data.json", Some("output.hedl"))?;