
Stream newline-delimited JSON (jsonlite's stream_in / stream_out)
Source:R/jsonlt_native.R
morie_jsonlt_stream_in.RdStream newline-delimited JSON (jsonlite's stream_in / stream_out)
Usage
morie_jsonlt_stream_in(
con,
handler = NULL,
pagesize = 500,
verbose = TRUE,
...
)
morie_jsonlt_stream_out(
x,
con = stdout(),
pagesize = 500,
verbose = TRUE,
prefix = "",
...
)Arguments
- con
a connection (opened in binary mode if not already open).
- handler
optional function called on each simplified page.
- pagesize
records per page.
- verbose
print progress.
- ...
passed to the simplifier / encoder.
- x
a data.frame to write, one record per line.
- prefix
text prepended to every line (the RFC 7464 record separator
"\x1e", for instance).
Examples
con <- textConnection(c('{"a":1,"b":"x"}', '{"a":2,"b":"y"}'))
morie_jsonlt_stream_in(con, verbose = FALSE)
#> a b
#> 1 1 x
#> 2 2 y
con <- textConnection("ndjson", "w")
morie_jsonlt_stream_out(data.frame(a = 1:3, b = c("x", "y", "z")), con, verbose = FALSE)
close(con)
ndjson
#> [1] "{\"a\":1,\"b\":\"x\"}" "{\"a\":2,\"b\":\"y\"}" "{\"a\":3,\"b\":\"z\"}"