From 59e95c015ef19512ab9ded6f26956782ea3b61b3 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Mon, 18 May 2015 21:57:59 +0100 Subject: [PATCH] Fixes problems introduced by #2738. Closes 2755. --- lib/pure/json.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 7d22e897b..518572be3 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -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]