Skip to content

Commit

Permalink
allow empty string key at the root object
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Jul 25, 2019
1 parent 3207e2e commit 43cddfb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gojo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ func TestGojoRun(t *testing.T) {
},
{
name: "deep keys",
args: []string{`a[b][c]d=e`, `a[b][c][d]=f`, `b[c][d][][]=f`, `b[c][d][]=g`, `c[][][]=d`},
expected: `{"a[b][c]d":"e","a":{"b":{"c":{"d":"f"}}},"b":{"c":{"d":[["f"],"g"]}},"c":[[["d"]]]}
args: []string{`a[b][c]d=e`, `a[b][c][d]=f`, `b[c][d][][]=f`, `b[c][d][]=g`, `c[][][]=d`, `[][][]=h`, `[][1][2]=i`},
expected: `{"a[b][c]d":"e","a":{"b":{"c":{"d":"f"}}},"b":{"c":{"d":[["f"],"g"]}},"c":[[["d"]]],"":[[["h"]],{"1":{"2":"i"}}]}
`,
},
{
Expand Down
2 changes: 1 addition & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func buildSetter(key string, value interface{}, inner bool) setter {
}
return &objectSetter{key, value}
}
if i > 0 {
if i > 0 || !inner {
s := buildSetter(key[i:], value, true)
if s == nil {
if inner {
Expand Down

0 comments on commit 43cddfb

Please sign in to comment.