Fixes problems introduced by #2738. Closes 2755.
This commit is contained in:
parent
f85dab3076
commit
59e95c015e
1 changed files with 6 additions and 4 deletions
|
|
@ -970,15 +970,12 @@ proc toUgly*(result: var string, node: JsonNode) =
|
|||
for key, value in items(node.fields):
|
||||
if comma: result.add ","
|
||||
else: comma = true
|
||||
result.add "\""
|
||||
result.add key.escapeJson()
|
||||
result.add "\":"
|
||||
result.add ":"
|
||||
result.toUgly value
|
||||
result.add "}"
|
||||
of JString:
|
||||
result.add "\""
|
||||
result.add node.str.escapeJson()
|
||||
result.add "\""
|
||||
of JInt:
|
||||
result.add($node.num)
|
||||
of JFloat:
|
||||
|
|
@ -1215,6 +1212,11 @@ when isMainModule:
|
|||
testJson{["c", "d"]} = %true
|
||||
assert(testJson["c"]["d"].bval)
|
||||
|
||||
# test `$`
|
||||
let stringified = $testJson
|
||||
let parsedAgain = parseJson(stringified)
|
||||
assert(parsedAgain["b"].str == "asd")
|
||||
|
||||
# Bounds checking
|
||||
try:
|
||||
let a = testJson["a"][9]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue