For list input, each element of the list is written as a single JSON string. For data.frame input, each row of the data.frame is written as aJSON string.

write_ndjson_str(x, opts = list(), ...)

Arguments

x

data.frame or list to be written as multiple JSON strings

opts

Named list of serialization options. Usually created by opts_write_json()

...

Other named options can be used to override any options in opts. The valid named options are identical to arguments to opts_write_json()

Value

String containing multiple JSON strings separated by newlines.

See also

Other JSON Serializer: write_json_file(), write_json_str(), write_ndjson_file()

Examples

write_ndjson_str(head(mtcars))
#> [1] "{\"mpg\":21.0,\"cyl\":6.0,\"disp\":160.0,\"hp\":110.0,\"drat\":3.9,\"wt\":2.62,\"qsec\":16.46,\"vs\":0.0,\"am\":1.0,\"gear\":4.0,\"carb\":4.0}\n{\"mpg\":21.0,\"cyl\":6.0,\"disp\":160.0,\"hp\":110.0,\"drat\":3.9,\"wt\":2.875,\"qsec\":17.02,\"vs\":0.0,\"am\":1.0,\"gear\":4.0,\"carb\":4.0}\n{\"mpg\":22.8,\"cyl\":4.0,\"disp\":108.0,\"hp\":93.0,\"drat\":3.85,\"wt\":2.32,\"qsec\":18.61,\"vs\":1.0,\"am\":1.0,\"gear\":4.0,\"carb\":1.0}\n{\"mpg\":21.4,\"cyl\":6.0,\"disp\":258.0,\"hp\":110.0,\"drat\":3.08,\"wt\":3.215,\"qsec\":19.44,\"vs\":1.0,\"am\":0.0,\"gear\":3.0,\"carb\":1.0}\n{\"mpg\":18.7,\"cyl\":8.0,\"disp\":360.0,\"hp\":175.0,\"drat\":3.15,\"wt\":3.44,\"qsec\":17.02,\"vs\":0.0,\"am\":0.0,\"gear\":3.0,\"carb\":2.0}\n{\"mpg\":18.1,\"cyl\":6.0,\"disp\":225.0,\"hp\":105.0,\"drat\":2.76,\"wt\":3.46,\"qsec\":20.22,\"vs\":1.0,\"am\":0.0,\"gear\":3.0,\"carb\":1.0}"