diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2019-01-20 23:24:06 -0800 |
---|---|---|
committer | Arne Döring <arne.doering@gmx.net> | 2019-01-21 08:24:06 +0100 |
commit | 32a90f74063c3ee238a4909d8678720d93545014 (patch) | |
tree | 6fc811f7c3c206aaa42206c40f86e9bbd376206e | |
parent | 28b3c8d74dcc3b812c2a386af68a39d3f746edcc (diff) | |
download | Nim-32a90f74063c3ee238a4909d8678720d93545014.tar.gz |
fix json bug `[]=` misplaced (#10397)
-rw-r--r-- | lib/pure/json.nim | 10 |
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 |