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
This commit is contained in:
Ganesan Karuppasamy
2024-05-07 21:07:12 +02:00
committed by GitHub
parent cb48887b9f
commit 36482dfa5a
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -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
View File
@@ -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]`},