keys function

Operations on keys, or by keys

Operations on keys, or by keys

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.

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 jqr that has JSON and query params combined, which is passed from function to function when using the jqr DSL.
  • ...: 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)
  • Maintainer: Jeroen Ooms
  • License: MIT + file LICENSE
  • Last published: 2024-12-16