Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding [] to JSON output #3

Open
burninmedia opened this issue Mar 13, 2019 · 0 comments
Open

adding [] to JSON output #3

burninmedia opened this issue Mar 13, 2019 · 0 comments

Comments

@burninmedia
Copy link

burninmedia commented Mar 13, 2019

Example using HCL2JSON from NPM on osx
$cat ./0-terraform.tf

terraform {
required_version = "= 0.11.11"
}

$ hcl2json ./0-terraform.tf

{
"terraform": {
"required_version": "= 0.11.11"
}
}

Here are the same file contents and the JSON output using your HCL2JSON on a Ubuntu Trusty docker container.
root@0de8e7724845:~# cat test.tf

terraform {
required_version = "= 0.11.11"
}

root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf

{
"terraform": [
{
"required_version": "= 0.11.11"
}
]
}

Notice in the first example that there are no [] around the terraform subkeys. When I pipe this output to jq -r '.terraform' it works as expected but if I filter for a subkey like '.terraform.required_version' I get this error which I believe is due to the [] output from your tool.
root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf |jq -r '.terraform'

[
{
"required_version": "= 0.11.11"
}
]

root@0de8e7724845:~# ./go/bin/hcl2json ./test.tf |jq -r '.terraform.required_version'

jq:

error: Cannot index array with string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant