In order to better understand terraform I'd like to be able to translate HCL into the equivalent JSON. I got the HCL parser (https://github.com/hashicorp/hcl) to build and the tests to run but I don't see any command to take in an HCL file and output JSON.
There's a python implementation of HCL and it includes a utility that converts HCL to JSON, but it has some rather strange/unexpected behavior, and I would like to confirm that the behavior comes from the HCL language and isn't specific to the python implementation. e.g.
> cat foo.tf
service {
key = "aaa"
}
service {
key = 0x10
foo = "bar"
}
> hcltool foo.tf
{
"service": [
{
"foo": "bar",
"key": "aaa"
},
{
"key": 16
}
]
}
This site is useful for one-off conversions between HCL, JSON, and YAML: https://www.hcl2json.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With