Skip to content

Commit

Permalink
Fixed JSON.parse (object in array).
Browse files Browse the repository at this point in the history
  • Loading branch information
dop251 committed Nov 7, 2016
1 parent 699b08e commit 6594cd5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion builtin_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ func (r *Runtime) builtinJSON_decodeArray(d *json.Decoder) (*Object, error) {
if delim == ']' {
break
}
return nil, fmt.Errorf("Unexpected delimiter: %v, expecting ']'", delim)
}
value, err := r.builtinJSON_decodeToken(d, tok)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,15 @@ func TestJSONEscape(t *testing.T) {
testScript1(SCRIPT, asciiString(`"\\+1"`), t)
}

func TestJSONObjectInArray(t *testing.T) {
const SCRIPT = `
var a = "[{\"a\":1},{\"a\":2}]";
JSON.stringify(JSON.parse(a)) == a;
`

testScript1(SCRIPT, valueTrue, t)
}

/*
func TestArrayConcatSparse(t *testing.T) {
function foo(a,b,c)
Expand Down

0 comments on commit 6594cd5

Please sign in to comment.