hcl2: github.com/hashicorp/hcl2/hcl/json Index | Files

package json

import "github.com/hashicorp/hcl2/hcl/json"

Package json is the JSON parser for HCL. It parses JSON files and returns implementations of the core HCL structural interfaces in terms of the JSON data inside.

This is not a generic JSON parser. Instead, it deals with the mapping from the JSON information model to the HCL information model, using a number of hard-coded structural conventions.


Package Files

ast.go didyoumean.go doc.go navigation.go parser.go peeker.go public.go scanner.go structure.go tokentype_string.go

func Parse Uses

func Parse(src []byte, filename string) (*hcl.File, hcl.Diagnostics)

Parse attempts to parse the given buffer as JSON and, if successful, returns a hcl.File for the HCL configuration represented by it.

This is not a generic JSON parser. Instead, it deals only with the profile of JSON used to express HCL configuration.

The returned file is valid only if the returned diagnostics returns false from its HasErrors method. If HasErrors returns true, the file represents the subset of data that was able to be parsed, which may be none.

func ParseFile Uses

func ParseFile(filename string) (*hcl.File, hcl.Diagnostics)

ParseFile is a convenience wrapper around Parse that first attempts to load data from the given filename, passing the result to Parse if successful.

If the file cannot be read, an error diagnostic with nil context is returned.

Package json imports 13 packages (graph) and is imported by 7 packages. Updated 2019-06-18. Refresh now. Tools for package owners.