Removed simpleGetOrDefault (#13590)

This commit is contained in:
Andreas Rumpf 2020-03-05 21:03:39 +01:00 • committed by GitHub
commit cb0f7c5d9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -523,8 +523,10 @@ proc getOrDefault*(node: JsonNode, key: string): JsonNode =
if not isNil(node) and node.kind == JObject: if not isNil(node) and node.kind == JObject:
result = node.fields.getOrDefault(key) result = node.fields.getOrDefault(key)
template simpleGetOrDefault*{`{}`(node, [key])}(node: JsonNode, proc `{}`*(node: JsonNode, key: string): JsonNode =
key: string): JsonNode = node.getOrDefault(key) ## Gets a field from a `node`. If `node` is nil or not an object or
## value at `key` does not exist, returns nil
node.getOrDefault(key)
proc `{}=`*(node: JsonNode, keys: varargs[string], value: JsonNode) = proc `{}=`*(node: JsonNode, keys: varargs[string], value: JsonNode) =
## Traverses the node and tries to set the value at the given location ## Traverses the node and tries to set the value at the given location