keys {jqr} | R Documentation |
Operations on keys, or by keys
Description
keys
takes no input, and retrieves keys. del
deletes
provided keys. haskey
checks if a json string has a key, or the
input array has an element at the given index.
Usage
keys(.data)
del(.data, ...)
del_(.data, ..., .dots)
haskey(.data, ...)
haskey_(.data, ..., .dots)
Arguments
.data |
input. This can be JSON input, or an object of class
|
... |
Comma separated list of unquoted variable names |
.dots |
Used to work around non-standard evaluation |
dots |
dots |
Examples
# get keys
str <- '{"foo": 5, "bar": 7}'
jq(str, "keys")
str %>% keys()
# delete by key name
jq(str, "del(.bar)")
str %>% del(bar)
# check for key existence
str3 <- '[[0,1], ["a","b","c"]]'
jq(str3, "map(has(2))")
str3 %>% haskey(2)
jq(str3, "map(has(1,2))")
str3 %>% haskey(1,2)
## many JSON inputs
'{"foo": 5, "bar": 7} {"hello": 5, "world": 7}' %>% keys
'{"foo": 5, "bar": 7} {"hello": 5, "bar": 7}' %>% del(bar)
[Package jqr version 1.3.3 Index]