summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2019-01-20 23:24:06 -0800
committerArne Döring <arne.doering@gmx.net>2019-01-21 08:24:06 +0100
commit32a90f74063c3ee238a4909d8678720d93545014 (patch)
tree6fc811f7c3c206aaa42206c40f86e9bbd376206e
parent28b3c8d74dcc3b812c2a386af68a39d3f746edcc (diff)
downloadNim-32a90f74063c3ee238a4909d8678720d93545014.tar.gz
fix json bug `[]=` misplaced (#10397)
-rw-r--r--lib/pure/json.nim10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 02fa6dc67..cf979e2d0 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -357,6 +357,11 @@ when false:
     assert false notin elements, "usage error: only empty sets allowed"
     assert true notin elements, "usage error: only empty sets allowed"
 
+proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} =
+  ## Sets a field from a `JObject`.
+  assert(obj.kind == JObject)
+  obj.fields[key] = val
+
 #[
 Note: could use simply:
 proc `%`*(o: object|tuple): JsonNode
@@ -522,11 +527,6 @@ proc contains*(node: JsonNode, val: JsonNode): bool =
 proc existsKey*(node: JsonNode, key: string): bool {.deprecated: "use hasKey instead".} = node.hasKey(key)
   ## **Deprecated:** use `hasKey` instead.
 
-proc `[]=`*(obj: JsonNode, key: string, val: JsonNode) {.inline.} =
-  ## Sets a field from a `JObject`.
-  assert(obj.kind == JObject)
-  obj.fields[key] = val
-
 proc `{}`*(node: JsonNode, keys: varargs[string]): JsonNode =
   ## Traverses the node and gets the given value. If any of the
   ## keys do not exist, returns ``nil``. Also returns ``nil`` if one of the