Convert R object to a raw vector of JSON data
write_json_raw(x, opts = list(), ...)the object to be encoded
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 the JSON
Other JSON Serializer:
write_json_file(),
write_json_str(),
write_ndjson_file(),
write_ndjson_raw(),
write_ndjson_str()
js <- write_json_raw(head(iris, 3))
js
#> [1] 5b 7b 22 53 65 70 61 6c 2e 4c 65 6e 67 74 68 22 3a 35 2e 31 2c 22 53 65 70
#> [26] 61 6c 2e 57 69 64 74 68 22 3a 33 2e 35 2c 22 50 65 74 61 6c 2e 4c 65 6e 67
#> [51] 74 68 22 3a 31 2e 34 2c 22 50 65 74 61 6c 2e 57 69 64 74 68 22 3a 30 2e 32
#> [76] 2c 22 53 70 65 63 69 65 73 22 3a 22 73 65 74 6f 73 61 22 7d 2c 7b 22 53 65
#> [101] 70 61 6c 2e 4c 65 6e 67 74 68 22 3a 34 2e 39 2c 22 53 65 70 61 6c 2e 57 69
#> [126] 64 74 68 22 3a 33 2e 30 2c 22 50 65 74 61 6c 2e 4c 65 6e 67 74 68 22 3a 31
#> [151] 2e 34 2c 22 50 65 74 61 6c 2e 57 69 64 74 68 22 3a 30 2e 32 2c 22 53 70 65
#> [176] 63 69 65 73 22 3a 22 73 65 74 6f 73 61 22 7d 2c 7b 22 53 65 70 61 6c 2e 4c
#> [201] 65 6e 67 74 68 22 3a 34 2e 37 2c 22 53 65 70 61 6c 2e 57 69 64 74 68 22 3a
#> [226] 33 2e 32 2c 22 50 65 74 61 6c 2e 4c 65 6e 67 74 68 22 3a 31 2e 33 2c 22 50
#> [251] 65 74 61 6c 2e 57 69 64 74 68 22 3a 30 2e 32 2c 22 53 70 65 63 69 65 73 22
#> [276] 3a 22 73 65 74 6f 73 61 22 7d 5d 00
read_json_raw(js)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3.0 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa