kvz / json2hcl

Convert JSON to HCL, and vice versa. We don't use json2hcl anymore ourselves, so we can't invest time into it. However, we're still welcoming PRs.
https://github.com/kvz/json2hcl
MIT License
498 stars 100 forks source link

Error converting nested lists #11

Closed burck1 closed 1 year ago

burck1 commented 5 years ago

I ran into an issue converting a list of lists. I was converting terraform-aws-vpn-gateway complete-dual-vpn-gateway example to json and ran into the message unable to parse HCL: At 58:74: expected: IDENT | STRING | ASSIGN | LBRACE got: RBRACK.

Here is a simplified example outlining the problem. A forward conversion produces no output.

$ json2hcl << EOM
{
  "locals": [
    {
      "public_subnets": [
        [
          "10.10.11.0/24",
          "10.10.12.0/24",
          "10.10.13.0/24"
        ]
      ]
    }
  ]
}
EOM

and a reverse conversion produces an error.

$ json2hcl -reverse << EOM
locals {
  public_subnets = [["10.10.11.0/24", "10.10.12.0/24", "10.10.13.0/24"]]
}
EOM
unable to parse HCL: At 2:72: expected: IDENT | STRING | ASSIGN | LBRACE got: RBRACK

My system info:

$ json2hcl -version 
v0.0.6
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.2
BuildVersion:   18C54
$ uname -mrps
Darwin 18.2.0 x86_64 i386
Acconut commented 5 years ago

Thank you very much for bringing this to our attention. However, I am very sorry to say that I currently don't have the time to look into your problem. I hope someone else can step up and assist you.