jsonElemsAt: Sub-array of a JSON array

Description Usage Arguments Value See Also Examples

Description

Returns a sub-array of a JSON array by giving the desired indices.

Usage

1
jsonElemsAt(json, indices, toJSON = FALSE, fromJSON = FALSE)

Arguments

json

json string

indices

integer vector

toJSON

logical, whether to apply toJSON to the input

fromJSON

logical, whether to apply fromJSON to the output

Value

A json string if fromJSON=FALSE, a R object if fromJSON=TRUE.

See Also

jsonElemAt, jsonAccess

Examples

1
2
3
4
5
6
7
json <- "{\"a\":{\"b\":8,\"c\":[0,1,\"hello\"]},\"b\":null}"
( arr <- jsonAccess(json, c("a","c")) )
jsonElemsAt(arr, c(0,2))
jsonElemsAt(arr, 2)
jsonElemsAt(arr, c(1,3))
# chain with the pipe operator:
jsonAccess(json, c("a","c")) %>% jsonElemsAt(2)

stla/jsonAccess documentation built on May 30, 2019, 5:47 p.m.