rjson (version 0.2.15)

fromJSON: Convert JSON To R

Description

Convert a JSON object into an R object.

Usage

fromJSON( json_str, file, method = "C", unexpected.escape = "error" )

Arguments

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 C implementation, or the older slower (and one day to be depricated) R implementation

unexpected.escape

changed handling of unexpected escaped characters. Handling value should be one of "error", "skip", or "keep"; on unexpected characters issue an error, skip the character, or keep the character

Value

R object that corresponds to the JSON object

See Also

toJSON

Examples

Run this code
# NOT RUN {
#watch out for R turning null into FALSE
fromJSON( "[true, false, null]" )
##[1]  TRUE FALSE __FALSE__

#but if you use a hash, this will be avoided
fromJSON( '{"a":true, "b":false, "c":null}' )


#R vs C
x <- toJSON( iris )
system.time( y <- fromJSON(x) )
system.time( y2 <- fromJSON(x,method = "R") )

# }

Run the code above in your browser using DataLab