Skip to contents

Read and write JSON files

Usage

morie_jsonlt_read_json(path, simplifyVector = FALSE, ...)

morie_jsonlt_write_json(x, path, ...)

Arguments

path

file path.

simplifyVector

as in jsonlite (FALSE by default for files).

...

options of morie_jsonlt_from_json() / morie_jsonlt_to_json().

x

object to write.

Value

read_json: the parsed object; write_json: path, invisibly.

Examples

f <- tempfile(fileext = ".json")
writeLines('{"a": 1, "b": [1, 2, 3]}', f)
str(morie_jsonlt_read_json(f, simplifyVector = TRUE))
#> List of 2
#>  $ a: int 1
#>  $ b: int [1:3] 1 2 3
f <- tempfile(fileext = ".json")
morie_jsonlt_write_json(list(a = 1, b = "x"), f)
readLines(f)
#> [1] "{\"a\":[1],\"b\":[\"x\"]}"