summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorMamy Ratsimbazafy <mratsim@users.noreply.github.com>2017-09-16 20:09:44 +0200
committerDominik Picheta <dominikpicheta@googlemail.com>2017-09-16 19:09:44 +0100
commit5b8f33a9058b78e2e714ce341107ac52d98dcc5f (patch)
tree8eb98fe9ce18706e84366b8e2be8185b205924cc /lib/pure
parent12af4a3f8ac290f5c6f7d208f1a1951a141449ff (diff)
downloadNim-5b8f33a9058b78e2e714ce341107ac52d98dcc5f.tar.gz
Reorder json `add` and `%`, fixes #6385 (#6388)
* Reorder json `add` and `%`, fixes https://github.com/nim-lang/Nim/issues/6385

* rename json test files
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/json.nim20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 097952588..73c4f97f4 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -721,6 +721,16 @@ proc getElems*(n: JsonNode, default: seq[JsonNode] = @[]): seq[JsonNode] =
   if n.isNil or n.kind != JArray: return default
   else: return n.elems
 
+proc add*(father, child: JsonNode) =
+  ## Adds `child` to a JArray node `father`.
+  assert father.kind == JArray
+  father.elems.add(child)
+
+proc add*(obj: JsonNode, key: string, val: JsonNode) =
+  ## Sets a field from a `JObject`.
+  assert obj.kind == JObject
+  obj.fields[key] = val
+
 proc `%`*(s: string): JsonNode =
   ## Generic constructor for JSON data. Creates a new `JString JsonNode`.
   new(result)
@@ -909,16 +919,6 @@ proc contains*(node: JsonNode, val: JsonNode): bool =
 proc existsKey*(node: JsonNode, key: string): bool {.deprecated.} = node.hasKey(key)
   ## Deprecated for `hasKey`
 
-proc add*(father, child: JsonNode) =
-  ## Adds `child` to a JArray node `father`.
-  assert father.kind == JArray
-  father.elems.add(child)
-
-proc add*(obj: JsonNode, key: string, val: JsonNode) =
-  ## Sets a field from a `JObject`.
-  assert obj.kind == JObject
-  obj.fields[key] = val
-
 proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} =
   ## Sets a field from a `JObject`.
   assert(obj.kind == JObject)