Implemented in operator support for JsonNode objects
This commit is contained in:
parent
9837b12ee6
commit
d913ec1685
1 changed files with 10 additions and 0 deletions
|
|
@ -848,6 +848,16 @@ proc hasKey*(node: JsonNode, key: string): bool =
|
||||||
assert(node.kind == JObject)
|
assert(node.kind == JObject)
|
||||||
result = node.fields.hasKey(key)
|
result = node.fields.hasKey(key)
|
||||||
|
|
||||||
|
proc contains*(node: JsonNode, key: string): bool =
|
||||||
|
## Checks if `key` exists in `node`.
|
||||||
|
assert(node.kind == JObject)
|
||||||
|
node.fields.hasKey(key)
|
||||||
|
|
||||||
|
proc contains*(node: JsonNode, val: JsonNode): bool =
|
||||||
|
## Checks if `val` exists in array `node`.
|
||||||
|
assert(node.kind == JArray)
|
||||||
|
find(node.elems, val) >= 0
|
||||||
|
|
||||||
proc existsKey*(node: JsonNode, key: string): bool {.deprecated.} = node.hasKey(key)
|
proc existsKey*(node: JsonNode, key: string): bool {.deprecated.} = node.hasKey(key)
|
||||||
## Deprecated for `hasKey`
|
## Deprecated for `hasKey`
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue