fix json bug []= misplaced (#10397)

This commit is contained in:
Timothee Cour 2019-01-20 23:24:06 -08:00 • committed by Arne Döring
commit 32a90f7406

View file

@ -357,6 +357,11 @@ when false:
assert false notin elements, "usage error: only empty sets allowed" assert false notin elements, "usage error: only empty sets allowed"
assert true 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: Note: could use simply:
proc `%`*(o: object|tuple): JsonNode 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) proc existsKey*(node: JsonNode, key: string): bool {.deprecated: "use hasKey instead".} = node.hasKey(key)
## **Deprecated:** use `hasKey` instead. ## **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 = proc `{}`*(node: JsonNode, keys: varargs[string]): JsonNode =
## Traverses the node and gets the given value. If any of the ## 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 ## keys do not exist, returns ``nil``. Also returns ``nil`` if one of the