summary refs log tree commit diff stats
path: root/lib/pure/json.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pure/json.nim')
-rwxr-xr-xlib/pure/json.nim3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 75958a55f..efadf030c 100755
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -620,7 +620,8 @@ proc nl(s: var string, ml: bool) =
 
 proc escapeJson*(s: string): string = 
   ## Converts a string `s` to its JSON representation.
-  result = "\""
+  result = newStringOfCap(s.len + s.len shr 3)
+  result.add("\"")
   for x in runes(s):
     var r = int(x)
     if r >= 32 and r <= 127: