json2hcl icon indicating copy to clipboard operation
json2hcl copied to clipboard

Wrong json output

Open nabouzidan-3as opened this issue 1 year ago • 1 comments

According to README, the conversion of

"output" "arn" {
  "value" = "${aws_dynamodb_table.basic-dynamodb-table.arn}"
}

will return

{
  "output": [
    {
      "arn": [
        {
          "value": "${aws_dynamodb_table.basic-dynamodb-table.arn}"
        }
      ]
    }, 
  ... rest of JSON truncated
  ]
}

This is not correct, the return value should be

{
  "output": {
      "arn": {
          "value": "${aws_dynamodb_table.basic-dynamodb-table.arn}"
        }
    }, 
  ... rest of JSON truncated
}

An HCL object is unnecessarily converted into a tuple.

nabouzidan-3as avatar Aug 23 '23 07:08 nabouzidan-3as

Similar errors have been reported many times (e.g. https://github.com/kvz/json2hcl/issues/4, #10). The problem is that the official HCL parser library that we use, does not produce the same output as you input because there are multiple serialized version for a given HCL file. This comment contains two links with more details: https://github.com/kvz/json2hcl/issues/4#issuecomment-275513256

Acconut avatar Aug 23 '23 07:08 Acconut