Unserialize selected elements from a tsjson object
Source:R/unserialize-json.R
unserialize_selected.Rd
Uses unserialize_json()
on the selected elements.
Details
If json
does not have a selection, then all of it is unserialized.
If json
has an empty selection, then an empty list is returned.
See also
unserialize_json()
to unserialize a JSON document from a
file or string. serialize_json()
to create JSON from R objects.
Examples
json <- load_json(text = serialize_json(list(
a = list(a1 = list(1,2,3), a2 = "string"),
b = list(4, 5, 6),
c = list(c1 = list("a", "b"))
)))
json |> select(c("b", "c")) |> unserialize_selected()
#> [[1]]
#> [[1]][[1]]
#> [1] 4
#>
#> [[1]][[2]]
#> [1] 5
#>
#> [[1]][[3]]
#> [1] 6
#>
#>
#> [[2]]
#> [[2]]$c1
#> [[2]]$c1[[1]]
#> [1] "a"
#>
#> [[2]]$c1[[2]]
#> [1] "b"
#>
#>
#>