We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The following code fails:
package main import ( "encoding/json" "reflect" "github.com/hashicorp/hcl" ) var hclData = []byte(`match "first" { type = "test" value = "first" } match "second" { type = "test" value = "second" match "inner" { type = "test" value = "third" } } `) type Data struct { Matches []*Match `json:"match" hcl:"match"` } type Match struct { Type string `json:"type" hcl:"type"` Value string `json:"value" hcl:"value"` Matches []*Match `json:"match,omitempty" hcl:"match"` } func main() { var d, e *Data err := hcl.Unmarshal(hclData, &d) if err != nil { panic("failed to unmarshal hclData: " + err.Error()) } jData, err := json.MarshalIndent(d, "", " ") if err != nil { panic("failed to marshal into jData: " + err.Error()) } err = hcl.Decode(&e, string(jData)) if err != nil { panic("failed to parse jData: " + err.Error()) } if !reflect.DeepEqual(d, e) { jd, _ := json.Marshal(d) je, _ := json.Marshal(e) panic("parsed data differs: \n" + string(jd) + "\n" + string(je) + "\n") } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The following code fails:
The text was updated successfully, but these errors were encountered: