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
parent 28b3c8d74d
commit 32a90f7406

View File

@@ -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