hashicorp / hashicorp/hcl

HCL -> json equivalency example in readme is wrong?

Open
#237 1 comment 2 reactions 0 assignees View on GitHub
v1
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

The readme says:
> ```hcl
> variable "ami" {
> description = "the AMI to use"
> }
> ```
> This would be equivalent to the following json:
> ```js
> {
> "variable": {
> "ami": {
> "description": "the AMI to use"
> }
> }
> }
> ```

However, based my usage of a [parser](https://github.com/kvz/json2hcl) (which admittedly might be out of date, though I built it with the latest version of this library) and the described functionality bellow:
> ... As an alternative, lists of objects can be created with repeated blocks, using this structure:
> ```hcl
> service {
> key = "value"
> }
>
> service {
> key = "value"
> }
> ```

The actual equivalency appears to be:
```hcl
variable "ami" {
description = "the AMI to use"
}
```
```js
{
"variable": [
{
"ami": [
{
"description": "the AMI to use"
}
]
}
]
}
```

Are my assumptions correct? Is my parser wrong? At the very least the readme is unclear about how the `lists of objects can be created with repeated blocks` deals with only having one declaration.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read the README's HCL-to-JSON equivalency example and its section on repeated blocks, then compare those statements with the linked json2hcl parser behavior. Done means confirming the correct representation and clarifying how a single block relates to the repeated-block form in the README.

Written by the indexing model from the issue text.

Assessment

Tech stack
json
Domain
documentation
Issue type
Documentation
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.