summaryrefslogtreecommitdiff
path: root/json/parser.go
diff options
context:
space:
mode:
authorKazuma Watanabe <watassbass@gmail.com>2020-08-25 02:53:10 +0900
committerGitHub <noreply@github.com>2020-08-24 10:53:10 -0700
commite72341df8ac7e995c125b20d4f05b4198587e2e6 (patch)
tree89f7d4e75ad58e7682ddaf8cf469fe83977460a9 /json/parser.go
parentb41530cb3607c4504afd222cab59cee6be47e2da (diff)
json: Add json.ParseWithStartPos function
This is like json.Parse but allows specifying a non-default start position, in case the caller is parsing a fragment from a larger JSON document.
Diffstat (limited to 'json/parser.go')
-rw-r--r--json/parser.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/json/parser.go b/json/parser.go
index 7a54c51..4e40068 100644
--- a/json/parser.go
+++ b/json/parser.go
@@ -8,15 +8,8 @@ import (
"github.com/zclconf/go-cty/cty"
)
-func parseFileContent(buf []byte, filename string) (node, hcl.Diagnostics) {
- tokens := scan(buf, pos{
- Filename: filename,
- Pos: hcl.Pos{
- Byte: 0,
- Line: 1,
- Column: 1,
- },
- })
+func parseFileContent(buf []byte, filename string, start hcl.Pos) (node, hcl.Diagnostics) {
+ tokens := scan(buf, pos{Filename: filename, Pos: start})
p := newPeeker(tokens)
node, diags := parseValue(p)
if len(diags) == 0 && p.Peek().Type != tokenEOF {