jsonAt: Access an element in a JSON string

Description Usage Arguments Value Examples

View source: R/jsonStrings.R

Description

Extract an element in a JSON string by giving a path of keys or indices.

Usage

1
jsonAt(jsonstring, path)

Arguments

jsonstring

a JSON string representing an array or an object

path

path to the element to extract; either a character vector of keys, an integer vector of indices, or a list made of keys and indices

Value

A JSON string.

Examples

1
2
3
4
jstring <- "[1,[\"a\",99],{\"x\":[2,3,4],\"y\":42}]"
jsonAt(jstring, 1)
jsonAt(jstring, list(2, "x"))
jsonAt(jstring, list(2, "z"))

jsonStrings documentation built on May 25, 2021, 5:08 p.m.