mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
Fixes problems introduced by #2738. Closes 2755.
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user