MCPcopy
hub / github.com/hashicorp/hcl / Parse

Function Parse

json/public.go:23–25  ·  view source on GitHub ↗

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

(src []byte, filename string)

Source from the content-addressed store, hash-verified

21// from its HasErrors method. If HasErrors returns true, the file represents
22// the subset of data that was able to be parsed, which may be none.
23func Parse(src []byte, filename string) (*hcl.File, hcl.Diagnostics) {
24 return ParseWithStartPos(src, filename, hcl.Pos{Byte: 0, Line: 1, Column: 1})
25}
26
27// ParseWithStartPos attempts to parse like json.Parse, but unlike json.Parse
28// you can pass a start position of the given JSON as a hcl.Pos.

Callers 15

DecodeFunction · 0.92
ParseJSONMethod · 0.92
TestGetTypeJSONFunction · 0.92
TestTerraformLikeFunction · 0.92
FuzzParseFunction · 0.92
ParseFileFunction · 0.85
TestBodyPartialContentFunction · 0.85
TestBodyContentFunction · 0.85
TestJustAttributesFunction · 0.85
TestExpressionVariablesFunction · 0.85
TestExpression_ValueFunction · 0.85

Calls 1

ParseWithStartPosFunction · 0.85

Tested by 15

TestGetTypeJSONFunction · 0.74
TestTerraformLikeFunction · 0.74
FuzzParseFunction · 0.74
TestBodyPartialContentFunction · 0.68
TestBodyContentFunction · 0.68
TestJustAttributesFunction · 0.68
TestExpressionVariablesFunction · 0.68
TestExpression_ValueFunction · 0.68
TestParse_nonObjectFunction · 0.68
TestParseTemplateFunction · 0.68