/hcl-rs

An HCL deserializer for rust

Primary LanguageRustMIT LicenseMIT

hcl-rs

Build Status docs.rs MIT License

This crate provides functionality to deserialize and manipulate HCL data.

The main types are Deserializer for deserializing data and Value which can be used to deserialize arbitrary HCL data.

Note: Serializing to HCL is not supported.

Example

use serde_json::{json, Value};

let input = r#"
    some_attr = {
      foo = [1, 2]
      bar = true
    }

    some_block "some_block_label" {
      attr = "value"
    }
"#;

let expected = json!({
    "some_attr": {
        "foo": [1, 2],
        "bar": true
    },
    "some_block": {
        "some_block_label": {
            "attr": "value"
        }
    }
});

let value: Value = hcl::from_str(input).unwrap();

assert_eq!(value, expected);

License

The source code of hcl-rs is released under the MIT License. See the bundled LICENSE file for details.