Skip to content

Commit 9207e71

Browse files
authored
Resolve double-escaping issue with pair node key (#640)
* Resolve double-escaping issue with pair node key * Resolve double-escaping issue with pair node key * Added test cases for pair node key
1 parent e6dfb71 commit 9207e71

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ast/print.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (n *PairNode) String() string {
215215
if utils.IsValidIdentifier(str.Value) {
216216
return fmt.Sprintf("%s: %s", str.Value, n.Value.String())
217217
}
218-
return fmt.Sprintf("%q: %s", str.String(), n.Value.String())
218+
return fmt.Sprintf("%s: %s", str.String(), n.Value.String())
219219
}
220220
return fmt.Sprintf("(%s): %s", n.Key.String(), n.Value.String())
221221
}

ast/print_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func TestPrint(t *testing.T) {
5757
{`{}`, `{}`},
5858
{`{a: b}`, `{a: b}`},
5959
{`{a: b, c: d}`, `{a: b, c: d}`},
60+
{`{"a": b, 'c': d}`, `{a: b, c: d}`},
61+
{`{"a": b, c: d}`, `{a: b, c: d}`},
62+
{`{"a": b, 8: 8}`, `{a: b, "8": 8}`},
63+
{`{"9": 9, '8': 8, "foo": d}`, `{"9": 9, "8": 8, foo: d}`},
6064
{`[]`, `[]`},
6165
{`[a]`, `[a]`},
6266
{`[a, b]`, `[a, b]`},

0 commit comments

Comments
 (0)