fromJSON | R Documentation |
Convert a JSON object into an R object.
fromJSON( json_str, file, method = "C", unexpected.escape = "error", simplify = TRUE )
json_str |
a JSON object to convert |
file |
the name of a file to read the json_str from; this can also be a URL. Only one of json_str or file must be supplied. |
method |
use the |
unexpected.escape |
changed handling of unexpected escaped characters. Handling value should be one of "error", "skip", or "keep"; on unexpected characters issue an |
simplify |
If TRUE, attempt to convert json-encoded lists into vectors where appropriate. If FALSE, all json-encoded lists will be wrapped in a list even if they are all of the same data type. |
R object that corresponds to the JSON object
toJSON
fromJSON('[1,2,3]', simplify=TRUE)
# returns c(1,2,3)
fromJSON('[1,2,3]', simplify=FALSE)
# returns list(1,2,3)
#As a result, this will output "1"
toJSON(fromJSON('[1]', simplify=TRUE))
#Compared with this which will output "[1]" as expected
toJSON(fromJSON('[1]', simplify=FALSE))
#R vs C execution time
x <- toJSON( iris )
system.time( y <- fromJSON(x) )
system.time( y2 <- fromJSON(x,method = "R") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.