-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
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
how to convert json to hcl using hclv2? #632
Comments
Hi @yaohy2014 ! You can use the Parse function. |
this function returned value is *hcl.File, I want the returned value is string. So is there any func to convert *hcl.File to string ? |
Hi @yaohy2014, HCL is a schema-driven system and the JSON variant relies on schema to resolve ambiguity caused by the limited JSON infoset. Therefore any tool that converts between the two syntaxes must be application-specific so it can know about the schema of the language being converted. HCL is just a toolkit for building languages, not a language itself. With that said, it's not typically necessary to convert between the two because applications that accept HCL should typically accept both syntaxes directly themselves, and so you can just pass the JSON variant directly to the application rather than converting it first as a separate step. That is why most existing HCL-based languages don't offer an external conversion mechanism: instead, they use the syntax-agnostic HCL API to abstract away the differences between the two at decoding time. |
Just posted this link in another Issue: https://medium.com/@peterbi_91340/marshal-and-unmarshal-hcl-files-1-3-d7591259a8d6 The package mentioned has also a CLI tool to convert between HCL and JSON. |
No description provided.
The text was updated successfully, but these errors were encountered: