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.
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);
The source code of hcl-rs is released under the MIT License. See the bundled LICENSE file for details.