Skip to content
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

Fix json parsing bug #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions gval_parsingFailure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ func TestParsingFailure(t *testing.T) {
expression: "0 + ,",
wantErr: `unexpected "," while scanning extensions`,
},
{
name: "Invalid json key:value structure",
expression: `{"a"=1}`,
wantErr: `unexpected "=" while scanning object expected ":"`,
},
},
t,
)
Expand Down
4 changes: 1 addition & 3 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,7 @@ func parseJSONObject(c context.Context, p *Parser) (Evaluable, error) {
return nil, err
}
if p.Scan() != ':' {
if err != nil {
return nil, p.Expected("object", ':')
}
return nil, p.Expected("object", ':')
}
value, err := p.ParseExpression(c)
if err != nil {
Expand Down