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_raw(x, opts = list(), ...)data.frame or list to be written as multiple JSON strings
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()
Raw vector containing NDJSON character data
Other JSON Serializer:
write_json_file(),
write_json_raw(),
write_json_str(),
write_ndjson_file(),
write_ndjson_str()
js <- write_ndjson_raw(head(mtcars))
js
#> [1] 7b 22 6d 70 67 22 3a 32 31 2e 30 2c 22 63 79 6c 22 3a 36 2e 30 2c 22 64 69
#> [26] 73 70 22 3a 31 36 30 2e 30 2c 22 68 70 22 3a 31 31 30 2e 30 2c 22 64 72 61
#> [51] 74 22 3a 33 2e 39 2c 22 77 74 22 3a 32 2e 36 32 2c 22 71 73 65 63 22 3a 31
#> [76] 36 2e 34 36 2c 22 76 73 22 3a 30 2e 30 2c 22 61 6d 22 3a 31 2e 30 2c 22 67
#> [101] 65 61 72 22 3a 34 2e 30 2c 22 63 61 72 62 22 3a 34 2e 30 7d 0a 7b 22 6d 70
#> [126] 67 22 3a 32 31 2e 30 2c 22 63 79 6c 22 3a 36 2e 30 2c 22 64 69 73 70 22 3a
#> [151] 31 36 30 2e 30 2c 22 68 70 22 3a 31 31 30 2e 30 2c 22 64 72 61 74 22 3a 33
#> [176] 2e 39 2c 22 77 74 22 3a 32 2e 38 37 35 2c 22 71 73 65 63 22 3a 31 37 2e 30
#> [201] 32 2c 22 76 73 22 3a 30 2e 30 2c 22 61 6d 22 3a 31 2e 30 2c 22 67 65 61 72
#> [226] 22 3a 34 2e 30 2c 22 63 61 72 62 22 3a 34 2e 30 7d 0a 7b 22 6d 70 67 22 3a
#> [251] 32 32 2e 38 2c 22 63 79 6c 22 3a 34 2e 30 2c 22 64 69 73 70 22 3a 31 30 38
#> [276] 2e 30 2c 22 68 70 22 3a 39 33 2e 30 2c 22 64 72 61 74 22 3a 33 2e 38 35 2c
#> [301] 22 77 74 22 3a 32 2e 33 32 2c 22 71 73 65 63 22 3a 31 38 2e 36 31 2c 22 76
#> [326] 73 22 3a 31 2e 30 2c 22 61 6d 22 3a 31 2e 30 2c 22 67 65 61 72 22 3a 34 2e
#> [351] 30 2c 22 63 61 72 62 22 3a 31 2e 30 7d 0a 7b 22 6d 70 67 22 3a 32 31 2e 34
#> [376] 2c 22 63 79 6c 22 3a 36 2e 30 2c 22 64 69 73 70 22 3a 32 35 38 2e 30 2c 22
#> [401] 68 70 22 3a 31 31 30 2e 30 2c 22 64 72 61 74 22 3a 33 2e 30 38 2c 22 77 74
#> [426] 22 3a 33 2e 32 31 35 2c 22 71 73 65 63 22 3a 31 39 2e 34 34 2c 22 76 73 22
#> [451] 3a 31 2e 30 2c 22 61 6d 22 3a 30 2e 30 2c 22 67 65 61 72 22 3a 33 2e 30 2c
#> [476] 22 63 61 72 62 22 3a 31 2e 30 7d 0a 7b 22 6d 70 67 22 3a 31 38 2e 37 2c 22
#> [501] 63 79 6c 22 3a 38 2e 30 2c 22 64 69 73 70 22 3a 33 36 30 2e 30 2c 22 68 70
#> [526] 22 3a 31 37 35 2e 30 2c 22 64 72 61 74 22 3a 33 2e 31 35 2c 22 77 74 22 3a
#> [551] 33 2e 34 34 2c 22 71 73 65 63 22 3a 31 37 2e 30 32 2c 22 76 73 22 3a 30 2e
#> [576] 30 2c 22 61 6d 22 3a 30 2e 30 2c 22 67 65 61 72 22 3a 33 2e 30 2c 22 63 61
#> [601] 72 62 22 3a 32 2e 30 7d 0a 7b 22 6d 70 67 22 3a 31 38 2e 31 2c 22 63 79 6c
#> [626] 22 3a 36 2e 30 2c 22 64 69 73 70 22 3a 32 32 35 2e 30 2c 22 68 70 22 3a 31
#> [651] 30 35 2e 30 2c 22 64 72 61 74 22 3a 32 2e 37 36 2c 22 77 74 22 3a 33 2e 34
#> [676] 36 2c 22 71 73 65 63 22 3a 32 30 2e 32 32 2c 22 76 73 22 3a 31 2e 30 2c 22
#> [701] 61 6d 22 3a 30 2e 30 2c 22 67 65 61 72 22 3a 33 2e 30 2c 22 63 61 72 62 22
#> [726] 3a 31 2e 30 7d 00
read_ndjson_raw(js, 'list')
#> [[1]]
#> [[1]]$mpg
#> [1] 21
#>
#> [[1]]$cyl
#> [1] 6
#>
#> [[1]]$disp
#> [1] 160
#>
#> [[1]]$hp
#> [1] 110
#>
#> [[1]]$drat
#> [1] 3.9
#>
#> [[1]]$wt
#> [1] 2.62
#>
#> [[1]]$qsec
#> [1] 16.46
#>
#> [[1]]$vs
#> [1] 0
#>
#> [[1]]$am
#> [1] 1
#>
#> [[1]]$gear
#> [1] 4
#>
#> [[1]]$carb
#> [1] 4
#>
#>
#> [[2]]
#> [[2]]$mpg
#> [1] 21
#>
#> [[2]]$cyl
#> [1] 6
#>
#> [[2]]$disp
#> [1] 160
#>
#> [[2]]$hp
#> [1] 110
#>
#> [[2]]$drat
#> [1] 3.9
#>
#> [[2]]$wt
#> [1] 2.875
#>
#> [[2]]$qsec
#> [1] 17.02
#>
#> [[2]]$vs
#> [1] 0
#>
#> [[2]]$am
#> [1] 1
#>
#> [[2]]$gear
#> [1] 4
#>
#> [[2]]$carb
#> [1] 4
#>
#>
#> [[3]]
#> [[3]]$mpg
#> [1] 22.8
#>
#> [[3]]$cyl
#> [1] 4
#>
#> [[3]]$disp
#> [1] 108
#>
#> [[3]]$hp
#> [1] 93
#>
#> [[3]]$drat
#> [1] 3.85
#>
#> [[3]]$wt
#> [1] 2.32
#>
#> [[3]]$qsec
#> [1] 18.61
#>
#> [[3]]$vs
#> [1] 1
#>
#> [[3]]$am
#> [1] 1
#>
#> [[3]]$gear
#> [1] 4
#>
#> [[3]]$carb
#> [1] 1
#>
#>
#> [[4]]
#> [[4]]$mpg
#> [1] 21.4
#>
#> [[4]]$cyl
#> [1] 6
#>
#> [[4]]$disp
#> [1] 258
#>
#> [[4]]$hp
#> [1] 110
#>
#> [[4]]$drat
#> [1] 3.08
#>
#> [[4]]$wt
#> [1] 3.215
#>
#> [[4]]$qsec
#> [1] 19.44
#>
#> [[4]]$vs
#> [1] 1
#>
#> [[4]]$am
#> [1] 0
#>
#> [[4]]$gear
#> [1] 3
#>
#> [[4]]$carb
#> [1] 1
#>
#>
#> [[5]]
#> [[5]]$mpg
#> [1] 18.7
#>
#> [[5]]$cyl
#> [1] 8
#>
#> [[5]]$disp
#> [1] 360
#>
#> [[5]]$hp
#> [1] 175
#>
#> [[5]]$drat
#> [1] 3.15
#>
#> [[5]]$wt
#> [1] 3.44
#>
#> [[5]]$qsec
#> [1] 17.02
#>
#> [[5]]$vs
#> [1] 0
#>
#> [[5]]$am
#> [1] 0
#>
#> [[5]]$gear
#> [1] 3
#>
#> [[5]]$carb
#> [1] 2
#>
#>
#> [[6]]
#> [[6]]$mpg
#> [1] 18.1
#>
#> [[6]]$cyl
#> [1] 6
#>
#> [[6]]$disp
#> [1] 225
#>
#> [[6]]$hp
#> [1] 105
#>
#> [[6]]$drat
#> [1] 2.76
#>
#> [[6]]$wt
#> [1] 3.46
#>
#> [[6]]$qsec
#> [1] 20.22
#>
#> [[6]]$vs
#> [1] 1
#>
#> [[6]]$am
#> [1] 0
#>
#> [[6]]$gear
#> [1] 3
#>
#> [[6]]$carb
#> [1] 1
#>
#>