json_path: Apply JSONPath to a json object

Description Usage Arguments Details Value Examples

View source: R/interface.R

Description

Takes a JSON object as loaded via the read_json function and applies a JSONPath query.

Usage

1
json_path(json, path, strict = TRUE, zero_index = TRUE, simplify = TRUE)

Arguments

json

a JSON object loaded by read_json

path

a JSONPath expression string, see details

strict

require JSONPath starts with '$.'

zero_index

numeric indices start from 0 rather than 1

simplify

convert simple list results to vectors

Details

JSONPath is an XPath-like language for querying JSON data, see http://goessner.net/articles/JsonPath/ for details.

Value

a list or vector of JSONPath results

Examples

1
2
3
4
5
6
## Not run: 
json <- read_json("bookstore.json")
authors <- json_path(json, "$.store.books[*].author")
# [1] "Nigel Rees"       "Evelyn Waugh"     "Herman Melville"  "J. R. R. Tolkien"

## End(Not run)

blmoore/rjsonpath documentation built on May 21, 2019, 2:21 p.m.