Skip to content

Commit

Permalink
Resolve double-escaping issue with pair node key (#640)
Browse files Browse the repository at this point in the history
* Resolve double-escaping issue with pair node key

* Resolve double-escaping issue with pair node key

* Added test cases for pair node key
  • Loading branch information
ckganesan authored May 7, 2024
1 parent e6dfb71 commit 9207e71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ast/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (n *PairNode) String() string {
if utils.IsValidIdentifier(str.Value) {
return fmt.Sprintf("%s: %s", str.Value, n.Value.String())
}
return fmt.Sprintf("%q: %s", str.String(), n.Value.String())
return fmt.Sprintf("%s: %s", str.String(), n.Value.String())
}
return fmt.Sprintf("(%s): %s", n.Key.String(), n.Value.String())
}
4 changes: 4 additions & 0 deletions ast/print_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func TestPrint(t *testing.T) {
{`{}`, `{}`},
{`{a: b}`, `{a: b}`},
{`{a: b, c: d}`, `{a: b, c: d}`},
{`{"a": b, 'c': d}`, `{a: b, c: d}`},
{`{"a": b, c: d}`, `{a: b, c: d}`},
{`{"a": b, 8: 8}`, `{a: b, "8": 8}`},
{`{"9": 9, '8': 8, "foo": d}`, `{"9": 9, "8": 8, foo: d}`},
{`[]`, `[]`},
{`[a]`, `[a]`},
{`[a, b]`, `[a, b]`},
Expand Down

0 comments on commit 9207e71

Please sign in to comment.