hashicorp / hashicorp/hcl

hcl to json produces an unexpected result

Open
#248 0 comments 1 reaction 0 assignees View on GitHub
v1
Dominant language
Go
Stars
5.8k
Forks
659
Avg merge
20h 36m
Merged PRs (30d)
6

Description

### HCL Template
```hcl
variable "ami" {
description = "the AMI to use"
}
```

According to the documentation the JSON equivalent is:
screen shot 2018-05-10 at 16 59 06

But Actually.. when using json2hcl --reverse on that hcl template, the output is this:
```json
{
"variable": [
{
"ami": [
{
"description": "the AMI to use"
}
]
}
]
}
```

So.. What's going on here? Is the documentation bad? is the decoder broken?

There is vast difference between holding these values nested in an array or not in an array

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the HCL example with `json2hcl --reverse` and compare its JSON output with the documented equivalent. Determine whether the decoder or the documentation is inconsistent, then make the behavior and expected nested-array structure agree.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.