RJSONIO converts data between R objects and JSON text.
The main entry points are fromJSON() for parsing JSON and
toJSON() for serializing R objects.
Use fromJSON() with JSON text, a file path, or a
connection.
fromJSON('{"name": "RJSONIO", "active": true, "values": [1, 2, 3]}')
#> $name
#> [1] "RJSONIO"
#>
#> $active
#> [1] TRUE
#>
#> $values
#> [1] 1 2 3Character input that starts with { or [ is
treated as JSON content. A plain file path is read from disk.
Use toJSON() to serialize common R objects.
value <- list(
id = 1,
name = "RJSONIO",
values = c(1, 2, 3),
active = TRUE
)
json <- toJSON(value, pretty = TRUE)
cat(json)
#> {
#> "id" : 1,
#> "name" : "RJSONIO",
#> "values" : [
#> 1,
#> 2,
#> 3
#> ],
#> "active" : true
#> }The result can be parsed back into R.
isValidJSON() checks whether JSON text can be
parsed.
Round trips are most direct for simple vectors and lists whose JSON representation maps cleanly back to base R types.
Need a high-speed mirror for your open-source project?
Contact our mirror admin team at info@clientvps.com.
This archive is provided as a free public service to the community.
Proudly supported by infrastructure from VPSPulse , RxServers , BuyNumber , UnitVPS , OffshoreName and secure payment technology by ArionPay.