Learn R Programming

raveio (version 0.9.0)

save_json: Save or load R object in 'JSON' format

Description

Save or load R object in 'JSON' format

Usage

save_json(
  x,
  con = stdout(),
  ...,
  digits = ceiling(-log10(.Machine$double.eps)),
  pretty = TRUE,
  serialize = TRUE
)

load_json(con, ..., map = NULL)

Value

save_json returns nothing; load_json returns an R object.

Arguments

x

R object to save

con

file or connection

...

other parameters to pass into toJSON or fromJSON

digits

number of digits to save

pretty

whether the output should be pretty

serialize

whether to save a serialized version of x; see 'Examples'.

map

a map to save the results

Examples

Run this code


# Serialize
save_json(list(a = 1, b = function(){}))

# use toJSON
save_json(list(a = 1, b = function(){}), serialize = FALSE)


# Demo of using serializer
f1 <- tempfile(fileext = ".json")
save_json(x ~ y + 1, f1)

load_json(f1)

unlink(f1)


Run the code above in your browser using DataLab