format_data_json.Rd
Viya MAS requires a very specific json format which is the goal of this function to create
format_data_json(df, scr = FALSE, scr_batch = FALSE, metadata_columns = NULL)
data frame to be transformed in JSON format rows
boolean, if TRUE
will write the new json format with metadata
boolean, if TRUE
will write the batch format JSON for SCR, metadata is ignored
columns names to be used as metadata. If scr is set to FALSE
, metatada_columns is ignored
a vector of JSON strings or a single json string when scr_batch
is set to TRUE
json_output <- format_data_json(mtcars)
json_output
#> : 1
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 21 }, {\"name\": \"cyl\", \"value\": 6 }, {\"name\": \"disp\", \"value\": 160 }, {\"name\": \"hp\", \"value\": 110 }, {\"name\": \"drat\", \"value\": 3.9 }, {\"name\": \"wt\", \"value\": 2.62 }, {\"name\": \"qsec\", \"value\": 16.46 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 2
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 21 }, {\"name\": \"cyl\", \"value\": 6 }, {\"name\": \"disp\", \"value\": 160 }, {\"name\": \"hp\", \"value\": 110 }, {\"name\": \"drat\", \"value\": 3.9 }, {\"name\": \"wt\", \"value\": 2.875 }, {\"name\": \"qsec\", \"value\": 17.02 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 3
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 22.8 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 108 }, {\"name\": \"hp\", \"value\": 93 }, {\"name\": \"drat\", \"value\": 3.85 }, {\"name\": \"wt\", \"value\": 2.32 }, {\"name\": \"qsec\", \"value\": 18.61 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 1 }] }"
#> ------------------------------------------------------------
#> : 4
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 21.4 }, {\"name\": \"cyl\", \"value\": 6 }, {\"name\": \"disp\", \"value\": 258 }, {\"name\": \"hp\", \"value\": 110 }, {\"name\": \"drat\", \"value\": 3.08 }, {\"name\": \"wt\", \"value\": 3.215 }, {\"name\": \"qsec\", \"value\": 19.44 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 1 }] }"
#> ------------------------------------------------------------
#> : 5
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 18.7 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 360 }, {\"name\": \"hp\", \"value\": 175 }, {\"name\": \"drat\", \"value\": 3.15 }, {\"name\": \"wt\", \"value\": 3.44 }, {\"name\": \"qsec\", \"value\": 17.02 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 6
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 18.1 }, {\"name\": \"cyl\", \"value\": 6 }, {\"name\": \"disp\", \"value\": 225 }, {\"name\": \"hp\", \"value\": 105 }, {\"name\": \"drat\", \"value\": 2.76 }, {\"name\": \"wt\", \"value\": 3.46 }, {\"name\": \"qsec\", \"value\": 20.22 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 1 }] }"
#> ------------------------------------------------------------
#> : 7
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 14.3 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 360 }, {\"name\": \"hp\", \"value\": 245 }, {\"name\": \"drat\", \"value\": 3.21 }, {\"name\": \"wt\", \"value\": 3.57 }, {\"name\": \"qsec\", \"value\": 15.84 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 8
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 24.4 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 146.7 }, {\"name\": \"hp\", \"value\": 62 }, {\"name\": \"drat\", \"value\": 3.69 }, {\"name\": \"wt\", \"value\": 3.19 }, {\"name\": \"qsec\", \"value\": 20 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 9
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 22.8 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 140.8 }, {\"name\": \"hp\", \"value\": 95 }, {\"name\": \"drat\", \"value\": 3.92 }, {\"name\": \"wt\", \"value\": 3.15 }, {\"name\": \"qsec\", \"value\": 22.9 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 10
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 19.2 }, {\"name\": \"cyl\", \"value\": 6 }, {\"name\": \"disp\", \"value\": 167.6 }, {\"name\": \"hp\", \"value\": 123 }, {\"name\": \"drat\", \"value\": 3.92 }, {\"name\": \"wt\", \"value\": 3.44 }, {\"name\": \"qsec\", \"value\": 18.3 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 11
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 17.8 }, {\"name\": \"cyl\", \"value\": 6 }, {\"name\": \"disp\", \"value\": 167.6 }, {\"name\": \"hp\", \"value\": 123 }, {\"name\": \"drat\", \"value\": 3.92 }, {\"name\": \"wt\", \"value\": 3.44 }, {\"name\": \"qsec\", \"value\": 18.9 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 12
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 16.4 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 275.8 }, {\"name\": \"hp\", \"value\": 180 }, {\"name\": \"drat\", \"value\": 3.07 }, {\"name\": \"wt\", \"value\": 4.07 }, {\"name\": \"qsec\", \"value\": 17.4 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 3 }] }"
#> ------------------------------------------------------------
#> : 13
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 17.3 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 275.8 }, {\"name\": \"hp\", \"value\": 180 }, {\"name\": \"drat\", \"value\": 3.07 }, {\"name\": \"wt\", \"value\": 3.73 }, {\"name\": \"qsec\", \"value\": 17.6 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 3 }] }"
#> ------------------------------------------------------------
#> : 14
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 15.2 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 275.8 }, {\"name\": \"hp\", \"value\": 180 }, {\"name\": \"drat\", \"value\": 3.07 }, {\"name\": \"wt\", \"value\": 3.78 }, {\"name\": \"qsec\", \"value\": 18 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 3 }] }"
#> ------------------------------------------------------------
#> : 15
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 10.4 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 472 }, {\"name\": \"hp\", \"value\": 205 }, {\"name\": \"drat\", \"value\": 2.93 }, {\"name\": \"wt\", \"value\": 5.25 }, {\"name\": \"qsec\", \"value\": 17.98 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 16
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 10.4 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 460 }, {\"name\": \"hp\", \"value\": 215 }, {\"name\": \"drat\", \"value\": 3 }, {\"name\": \"wt\", \"value\": 5.424 }, {\"name\": \"qsec\", \"value\": 17.82 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 17
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 14.7 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 440 }, {\"name\": \"hp\", \"value\": 230 }, {\"name\": \"drat\", \"value\": 3.23 }, {\"name\": \"wt\", \"value\": 5.345 }, {\"name\": \"qsec\", \"value\": 17.42 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 18
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 32.4 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 78.7 }, {\"name\": \"hp\", \"value\": 66 }, {\"name\": \"drat\", \"value\": 4.08 }, {\"name\": \"wt\", \"value\": 2.2 }, {\"name\": \"qsec\", \"value\": 19.47 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 1 }] }"
#> ------------------------------------------------------------
#> : 19
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 30.4 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 75.7 }, {\"name\": \"hp\", \"value\": 52 }, {\"name\": \"drat\", \"value\": 4.93 }, {\"name\": \"wt\", \"value\": 1.615 }, {\"name\": \"qsec\", \"value\": 18.52 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 20
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 33.9 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 71.1 }, {\"name\": \"hp\", \"value\": 65 }, {\"name\": \"drat\", \"value\": 4.22 }, {\"name\": \"wt\", \"value\": 1.835 }, {\"name\": \"qsec\", \"value\": 19.9 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 1 }] }"
#> ------------------------------------------------------------
#> : 21
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 21.5 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 120.1 }, {\"name\": \"hp\", \"value\": 97 }, {\"name\": \"drat\", \"value\": 3.7 }, {\"name\": \"wt\", \"value\": 2.465 }, {\"name\": \"qsec\", \"value\": 20.01 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 1 }] }"
#> ------------------------------------------------------------
#> : 22
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 15.5 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 318 }, {\"name\": \"hp\", \"value\": 150 }, {\"name\": \"drat\", \"value\": 2.76 }, {\"name\": \"wt\", \"value\": 3.52 }, {\"name\": \"qsec\", \"value\": 16.87 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 23
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 15.2 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 304 }, {\"name\": \"hp\", \"value\": 150 }, {\"name\": \"drat\", \"value\": 3.15 }, {\"name\": \"wt\", \"value\": 3.435 }, {\"name\": \"qsec\", \"value\": 17.3 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 24
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 13.3 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 350 }, {\"name\": \"hp\", \"value\": 245 }, {\"name\": \"drat\", \"value\": 3.73 }, {\"name\": \"wt\", \"value\": 3.84 }, {\"name\": \"qsec\", \"value\": 15.41 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 25
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 19.2 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 400 }, {\"name\": \"hp\", \"value\": 175 }, {\"name\": \"drat\", \"value\": 3.08 }, {\"name\": \"wt\", \"value\": 3.845 }, {\"name\": \"qsec\", \"value\": 17.05 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 0 }, {\"name\": \"gear\", \"value\": 3 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 26
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 27.3 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 79 }, {\"name\": \"hp\", \"value\": 66 }, {\"name\": \"drat\", \"value\": 4.08 }, {\"name\": \"wt\", \"value\": 1.935 }, {\"name\": \"qsec\", \"value\": 18.9 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 1 }] }"
#> ------------------------------------------------------------
#> : 27
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 26 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 120.3 }, {\"name\": \"hp\", \"value\": 91 }, {\"name\": \"drat\", \"value\": 4.43 }, {\"name\": \"wt\", \"value\": 2.14 }, {\"name\": \"qsec\", \"value\": 16.7 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 5 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 28
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 30.4 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 95.1 }, {\"name\": \"hp\", \"value\": 113 }, {\"name\": \"drat\", \"value\": 3.77 }, {\"name\": \"wt\", \"value\": 1.513 }, {\"name\": \"qsec\", \"value\": 16.9 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 5 }, {\"name\": \"carb\", \"value\": 2 }] }"
#> ------------------------------------------------------------
#> : 29
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 15.8 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 351 }, {\"name\": \"hp\", \"value\": 264 }, {\"name\": \"drat\", \"value\": 4.22 }, {\"name\": \"wt\", \"value\": 3.17 }, {\"name\": \"qsec\", \"value\": 14.5 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 5 }, {\"name\": \"carb\", \"value\": 4 }] }"
#> ------------------------------------------------------------
#> : 30
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 19.7 }, {\"name\": \"cyl\", \"value\": 6 }, {\"name\": \"disp\", \"value\": 145 }, {\"name\": \"hp\", \"value\": 175 }, {\"name\": \"drat\", \"value\": 3.62 }, {\"name\": \"wt\", \"value\": 2.77 }, {\"name\": \"qsec\", \"value\": 15.5 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 5 }, {\"name\": \"carb\", \"value\": 6 }] }"
#> ------------------------------------------------------------
#> : 31
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 15 }, {\"name\": \"cyl\", \"value\": 8 }, {\"name\": \"disp\", \"value\": 301 }, {\"name\": \"hp\", \"value\": 335 }, {\"name\": \"drat\", \"value\": 3.54 }, {\"name\": \"wt\", \"value\": 3.57 }, {\"name\": \"qsec\", \"value\": 14.6 }, {\"name\": \"vs\", \"value\": 0 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 5 }, {\"name\": \"carb\", \"value\": 8 }] }"
#> ------------------------------------------------------------
#> : 32
#> [1] "{\"inputs\": [ {\"name\": \"mpg\", \"value\": 21.4 }, {\"name\": \"cyl\", \"value\": 4 }, {\"name\": \"disp\", \"value\": 121 }, {\"name\": \"hp\", \"value\": 109 }, {\"name\": \"drat\", \"value\": 4.11 }, {\"name\": \"wt\", \"value\": 2.78 }, {\"name\": \"qsec\", \"value\": 18.6 }, {\"name\": \"vs\", \"value\": 1 }, {\"name\": \"am\", \"value\": 1 }, {\"name\": \"gear\", \"value\": 4 }, {\"name\": \"carb\", \"value\": 2 }] }"
json_output <- format_data_json(mtcars, scr = TRUE)
json_output
#> : 1
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 21 , \"cyl\": 6 , \"disp\": 160 , \"hp\": 110 , \"drat\": 3.9 , \"wt\": 2.62 , \"qsec\": 16.46 , \"vs\": 0 , \"am\": 1 , \"gear\": 4 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 2
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 21 , \"cyl\": 6 , \"disp\": 160 , \"hp\": 110 , \"drat\": 3.9 , \"wt\": 2.875 , \"qsec\": 17.02 , \"vs\": 0 , \"am\": 1 , \"gear\": 4 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 3
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 22.8 , \"cyl\": 4 , \"disp\": 108 , \"hp\": 93 , \"drat\": 3.85 , \"wt\": 2.32 , \"qsec\": 18.61 , \"vs\": 1 , \"am\": 1 , \"gear\": 4 , \"carb\": 1 } }"
#> ------------------------------------------------------------
#> : 4
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 21.4 , \"cyl\": 6 , \"disp\": 258 , \"hp\": 110 , \"drat\": 3.08 , \"wt\": 3.215 , \"qsec\": 19.44 , \"vs\": 1 , \"am\": 0 , \"gear\": 3 , \"carb\": 1 } }"
#> ------------------------------------------------------------
#> : 5
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 18.7 , \"cyl\": 8 , \"disp\": 360 , \"hp\": 175 , \"drat\": 3.15 , \"wt\": 3.44 , \"qsec\": 17.02 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 6
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 18.1 , \"cyl\": 6 , \"disp\": 225 , \"hp\": 105 , \"drat\": 2.76 , \"wt\": 3.46 , \"qsec\": 20.22 , \"vs\": 1 , \"am\": 0 , \"gear\": 3 , \"carb\": 1 } }"
#> ------------------------------------------------------------
#> : 7
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 14.3 , \"cyl\": 8 , \"disp\": 360 , \"hp\": 245 , \"drat\": 3.21 , \"wt\": 3.57 , \"qsec\": 15.84 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 8
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 24.4 , \"cyl\": 4 , \"disp\": 146.7 , \"hp\": 62 , \"drat\": 3.69 , \"wt\": 3.19 , \"qsec\": 20 , \"vs\": 1 , \"am\": 0 , \"gear\": 4 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 9
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 22.8 , \"cyl\": 4 , \"disp\": 140.8 , \"hp\": 95 , \"drat\": 3.92 , \"wt\": 3.15 , \"qsec\": 22.9 , \"vs\": 1 , \"am\": 0 , \"gear\": 4 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 10
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 19.2 , \"cyl\": 6 , \"disp\": 167.6 , \"hp\": 123 , \"drat\": 3.92 , \"wt\": 3.44 , \"qsec\": 18.3 , \"vs\": 1 , \"am\": 0 , \"gear\": 4 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 11
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 17.8 , \"cyl\": 6 , \"disp\": 167.6 , \"hp\": 123 , \"drat\": 3.92 , \"wt\": 3.44 , \"qsec\": 18.9 , \"vs\": 1 , \"am\": 0 , \"gear\": 4 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 12
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 16.4 , \"cyl\": 8 , \"disp\": 275.8 , \"hp\": 180 , \"drat\": 3.07 , \"wt\": 4.07 , \"qsec\": 17.4 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 3 } }"
#> ------------------------------------------------------------
#> : 13
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 17.3 , \"cyl\": 8 , \"disp\": 275.8 , \"hp\": 180 , \"drat\": 3.07 , \"wt\": 3.73 , \"qsec\": 17.6 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 3 } }"
#> ------------------------------------------------------------
#> : 14
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 15.2 , \"cyl\": 8 , \"disp\": 275.8 , \"hp\": 180 , \"drat\": 3.07 , \"wt\": 3.78 , \"qsec\": 18 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 3 } }"
#> ------------------------------------------------------------
#> : 15
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 10.4 , \"cyl\": 8 , \"disp\": 472 , \"hp\": 205 , \"drat\": 2.93 , \"wt\": 5.25 , \"qsec\": 17.98 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 16
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 10.4 , \"cyl\": 8 , \"disp\": 460 , \"hp\": 215 , \"drat\": 3 , \"wt\": 5.424 , \"qsec\": 17.82 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 17
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 14.7 , \"cyl\": 8 , \"disp\": 440 , \"hp\": 230 , \"drat\": 3.23 , \"wt\": 5.345 , \"qsec\": 17.42 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 18
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 32.4 , \"cyl\": 4 , \"disp\": 78.7 , \"hp\": 66 , \"drat\": 4.08 , \"wt\": 2.2 , \"qsec\": 19.47 , \"vs\": 1 , \"am\": 1 , \"gear\": 4 , \"carb\": 1 } }"
#> ------------------------------------------------------------
#> : 19
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 30.4 , \"cyl\": 4 , \"disp\": 75.7 , \"hp\": 52 , \"drat\": 4.93 , \"wt\": 1.615 , \"qsec\": 18.52 , \"vs\": 1 , \"am\": 1 , \"gear\": 4 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 20
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 33.9 , \"cyl\": 4 , \"disp\": 71.1 , \"hp\": 65 , \"drat\": 4.22 , \"wt\": 1.835 , \"qsec\": 19.9 , \"vs\": 1 , \"am\": 1 , \"gear\": 4 , \"carb\": 1 } }"
#> ------------------------------------------------------------
#> : 21
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 21.5 , \"cyl\": 4 , \"disp\": 120.1 , \"hp\": 97 , \"drat\": 3.7 , \"wt\": 2.465 , \"qsec\": 20.01 , \"vs\": 1 , \"am\": 0 , \"gear\": 3 , \"carb\": 1 } }"
#> ------------------------------------------------------------
#> : 22
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 15.5 , \"cyl\": 8 , \"disp\": 318 , \"hp\": 150 , \"drat\": 2.76 , \"wt\": 3.52 , \"qsec\": 16.87 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 23
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 15.2 , \"cyl\": 8 , \"disp\": 304 , \"hp\": 150 , \"drat\": 3.15 , \"wt\": 3.435 , \"qsec\": 17.3 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 24
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 13.3 , \"cyl\": 8 , \"disp\": 350 , \"hp\": 245 , \"drat\": 3.73 , \"wt\": 3.84 , \"qsec\": 15.41 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 25
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 19.2 , \"cyl\": 8 , \"disp\": 400 , \"hp\": 175 , \"drat\": 3.08 , \"wt\": 3.845 , \"qsec\": 17.05 , \"vs\": 0 , \"am\": 0 , \"gear\": 3 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 26
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 27.3 , \"cyl\": 4 , \"disp\": 79 , \"hp\": 66 , \"drat\": 4.08 , \"wt\": 1.935 , \"qsec\": 18.9 , \"vs\": 1 , \"am\": 1 , \"gear\": 4 , \"carb\": 1 } }"
#> ------------------------------------------------------------
#> : 27
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 26 , \"cyl\": 4 , \"disp\": 120.3 , \"hp\": 91 , \"drat\": 4.43 , \"wt\": 2.14 , \"qsec\": 16.7 , \"vs\": 0 , \"am\": 1 , \"gear\": 5 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 28
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 30.4 , \"cyl\": 4 , \"disp\": 95.1 , \"hp\": 113 , \"drat\": 3.77 , \"wt\": 1.513 , \"qsec\": 16.9 , \"vs\": 1 , \"am\": 1 , \"gear\": 5 , \"carb\": 2 } }"
#> ------------------------------------------------------------
#> : 29
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 15.8 , \"cyl\": 8 , \"disp\": 351 , \"hp\": 264 , \"drat\": 4.22 , \"wt\": 3.17 , \"qsec\": 14.5 , \"vs\": 0 , \"am\": 1 , \"gear\": 5 , \"carb\": 4 } }"
#> ------------------------------------------------------------
#> : 30
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 19.7 , \"cyl\": 6 , \"disp\": 145 , \"hp\": 175 , \"drat\": 3.62 , \"wt\": 2.77 , \"qsec\": 15.5 , \"vs\": 0 , \"am\": 1 , \"gear\": 5 , \"carb\": 6 } }"
#> ------------------------------------------------------------
#> : 31
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 15 , \"cyl\": 8 , \"disp\": 301 , \"hp\": 335 , \"drat\": 3.54 , \"wt\": 3.57 , \"qsec\": 14.6 , \"vs\": 0 , \"am\": 1 , \"gear\": 5 , \"carb\": 8 } }"
#> ------------------------------------------------------------
#> : 32
#> [1] "{\"metadata\": {}, \"data\": {\"mpg\": 21.4 , \"cyl\": 4 , \"disp\": 121 , \"hp\": 109 , \"drat\": 4.11 , \"wt\": 2.78 , \"qsec\": 18.6 , \"vs\": 1 , \"am\": 1 , \"gear\": 4 , \"carb\": 2 } }"
json_output <- format_data_json(mtcars, scr_batch = TRUE)
jsonlite::prettify(json_output)
#> {
#> "data": [
#> [
#> 1,
#> {
#> "mpg": 21,
#> "cyl": 6,
#> "disp": 160,
#> "hp": 110,
#> "drat": 3.9,
#> "wt": 2.62,
#> "qsec": 16.46,
#> "vs": 0,
#> "am": 1,
#> "gear": 4,
#> "carb": 4
#> }
#> ],
#> [
#> 2,
#> {
#> "mpg": 21,
#> "cyl": 6,
#> "disp": 160,
#> "hp": 110,
#> "drat": 3.9,
#> "wt": 2.875,
#> "qsec": 17.02,
#> "vs": 0,
#> "am": 1,
#> "gear": 4,
#> "carb": 4
#> }
#> ],
#> [
#> 3,
#> {
#> "mpg": 22.8,
#> "cyl": 4,
#> "disp": 108,
#> "hp": 93,
#> "drat": 3.85,
#> "wt": 2.32,
#> "qsec": 18.61,
#> "vs": 1,
#> "am": 1,
#> "gear": 4,
#> "carb": 1
#> }
#> ],
#> [
#> 4,
#> {
#> "mpg": 21.4,
#> "cyl": 6,
#> "disp": 258,
#> "hp": 110,
#> "drat": 3.08,
#> "wt": 3.215,
#> "qsec": 19.44,
#> "vs": 1,
#> "am": 0,
#> "gear": 3,
#> "carb": 1
#> }
#> ],
#> [
#> 5,
#> {
#> "mpg": 18.7,
#> "cyl": 8,
#> "disp": 360,
#> "hp": 175,
#> "drat": 3.15,
#> "wt": 3.44,
#> "qsec": 17.02,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 2
#> }
#> ],
#> [
#> 6,
#> {
#> "mpg": 18.1,
#> "cyl": 6,
#> "disp": 225,
#> "hp": 105,
#> "drat": 2.76,
#> "wt": 3.46,
#> "qsec": 20.22,
#> "vs": 1,
#> "am": 0,
#> "gear": 3,
#> "carb": 1
#> }
#> ],
#> [
#> 7,
#> {
#> "mpg": 14.3,
#> "cyl": 8,
#> "disp": 360,
#> "hp": 245,
#> "drat": 3.21,
#> "wt": 3.57,
#> "qsec": 15.84,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 4
#> }
#> ],
#> [
#> 8,
#> {
#> "mpg": 24.4,
#> "cyl": 4,
#> "disp": 146.7,
#> "hp": 62,
#> "drat": 3.69,
#> "wt": 3.19,
#> "qsec": 20,
#> "vs": 1,
#> "am": 0,
#> "gear": 4,
#> "carb": 2
#> }
#> ],
#> [
#> 9,
#> {
#> "mpg": 22.8,
#> "cyl": 4,
#> "disp": 140.8,
#> "hp": 95,
#> "drat": 3.92,
#> "wt": 3.15,
#> "qsec": 22.9,
#> "vs": 1,
#> "am": 0,
#> "gear": 4,
#> "carb": 2
#> }
#> ],
#> [
#> 10,
#> {
#> "mpg": 19.2,
#> "cyl": 6,
#> "disp": 167.6,
#> "hp": 123,
#> "drat": 3.92,
#> "wt": 3.44,
#> "qsec": 18.3,
#> "vs": 1,
#> "am": 0,
#> "gear": 4,
#> "carb": 4
#> }
#> ],
#> [
#> 11,
#> {
#> "mpg": 17.8,
#> "cyl": 6,
#> "disp": 167.6,
#> "hp": 123,
#> "drat": 3.92,
#> "wt": 3.44,
#> "qsec": 18.9,
#> "vs": 1,
#> "am": 0,
#> "gear": 4,
#> "carb": 4
#> }
#> ],
#> [
#> 12,
#> {
#> "mpg": 16.4,
#> "cyl": 8,
#> "disp": 275.8,
#> "hp": 180,
#> "drat": 3.07,
#> "wt": 4.07,
#> "qsec": 17.4,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 3
#> }
#> ],
#> [
#> 13,
#> {
#> "mpg": 17.3,
#> "cyl": 8,
#> "disp": 275.8,
#> "hp": 180,
#> "drat": 3.07,
#> "wt": 3.73,
#> "qsec": 17.6,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 3
#> }
#> ],
#> [
#> 14,
#> {
#> "mpg": 15.2,
#> "cyl": 8,
#> "disp": 275.8,
#> "hp": 180,
#> "drat": 3.07,
#> "wt": 3.78,
#> "qsec": 18,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 3
#> }
#> ],
#> [
#> 15,
#> {
#> "mpg": 10.4,
#> "cyl": 8,
#> "disp": 472,
#> "hp": 205,
#> "drat": 2.93,
#> "wt": 5.25,
#> "qsec": 17.98,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 4
#> }
#> ],
#> [
#> 16,
#> {
#> "mpg": 10.4,
#> "cyl": 8,
#> "disp": 460,
#> "hp": 215,
#> "drat": 3,
#> "wt": 5.424,
#> "qsec": 17.82,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 4
#> }
#> ],
#> [
#> 17,
#> {
#> "mpg": 14.7,
#> "cyl": 8,
#> "disp": 440,
#> "hp": 230,
#> "drat": 3.23,
#> "wt": 5.345,
#> "qsec": 17.42,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 4
#> }
#> ],
#> [
#> 18,
#> {
#> "mpg": 32.4,
#> "cyl": 4,
#> "disp": 78.7,
#> "hp": 66,
#> "drat": 4.08,
#> "wt": 2.2,
#> "qsec": 19.47,
#> "vs": 1,
#> "am": 1,
#> "gear": 4,
#> "carb": 1
#> }
#> ],
#> [
#> 19,
#> {
#> "mpg": 30.4,
#> "cyl": 4,
#> "disp": 75.7,
#> "hp": 52,
#> "drat": 4.93,
#> "wt": 1.615,
#> "qsec": 18.52,
#> "vs": 1,
#> "am": 1,
#> "gear": 4,
#> "carb": 2
#> }
#> ],
#> [
#> 20,
#> {
#> "mpg": 33.9,
#> "cyl": 4,
#> "disp": 71.1,
#> "hp": 65,
#> "drat": 4.22,
#> "wt": 1.835,
#> "qsec": 19.9,
#> "vs": 1,
#> "am": 1,
#> "gear": 4,
#> "carb": 1
#> }
#> ],
#> [
#> 21,
#> {
#> "mpg": 21.5,
#> "cyl": 4,
#> "disp": 120.1,
#> "hp": 97,
#> "drat": 3.7,
#> "wt": 2.465,
#> "qsec": 20.01,
#> "vs": 1,
#> "am": 0,
#> "gear": 3,
#> "carb": 1
#> }
#> ],
#> [
#> 22,
#> {
#> "mpg": 15.5,
#> "cyl": 8,
#> "disp": 318,
#> "hp": 150,
#> "drat": 2.76,
#> "wt": 3.52,
#> "qsec": 16.87,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 2
#> }
#> ],
#> [
#> 23,
#> {
#> "mpg": 15.2,
#> "cyl": 8,
#> "disp": 304,
#> "hp": 150,
#> "drat": 3.15,
#> "wt": 3.435,
#> "qsec": 17.3,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 2
#> }
#> ],
#> [
#> 24,
#> {
#> "mpg": 13.3,
#> "cyl": 8,
#> "disp": 350,
#> "hp": 245,
#> "drat": 3.73,
#> "wt": 3.84,
#> "qsec": 15.41,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 4
#> }
#> ],
#> [
#> 25,
#> {
#> "mpg": 19.2,
#> "cyl": 8,
#> "disp": 400,
#> "hp": 175,
#> "drat": 3.08,
#> "wt": 3.845,
#> "qsec": 17.05,
#> "vs": 0,
#> "am": 0,
#> "gear": 3,
#> "carb": 2
#> }
#> ],
#> [
#> 26,
#> {
#> "mpg": 27.3,
#> "cyl": 4,
#> "disp": 79,
#> "hp": 66,
#> "drat": 4.08,
#> "wt": 1.935,
#> "qsec": 18.9,
#> "vs": 1,
#> "am": 1,
#> "gear": 4,
#> "carb": 1
#> }
#> ],
#> [
#> 27,
#> {
#> "mpg": 26,
#> "cyl": 4,
#> "disp": 120.3,
#> "hp": 91,
#> "drat": 4.43,
#> "wt": 2.14,
#> "qsec": 16.7,
#> "vs": 0,
#> "am": 1,
#> "gear": 5,
#> "carb": 2
#> }
#> ],
#> [
#> 28,
#> {
#> "mpg": 30.4,
#> "cyl": 4,
#> "disp": 95.1,
#> "hp": 113,
#> "drat": 3.77,
#> "wt": 1.513,
#> "qsec": 16.9,
#> "vs": 1,
#> "am": 1,
#> "gear": 5,
#> "carb": 2
#> }
#> ],
#> [
#> 29,
#> {
#> "mpg": 15.8,
#> "cyl": 8,
#> "disp": 351,
#> "hp": 264,
#> "drat": 4.22,
#> "wt": 3.17,
#> "qsec": 14.5,
#> "vs": 0,
#> "am": 1,
#> "gear": 5,
#> "carb": 4
#> }
#> ],
#> [
#> 30,
#> {
#> "mpg": 19.7,
#> "cyl": 6,
#> "disp": 145,
#> "hp": 175,
#> "drat": 3.62,
#> "wt": 2.77,
#> "qsec": 15.5,
#> "vs": 0,
#> "am": 1,
#> "gear": 5,
#> "carb": 6
#> }
#> ],
#> [
#> 31,
#> {
#> "mpg": 15,
#> "cyl": 8,
#> "disp": 301,
#> "hp": 335,
#> "drat": 3.54,
#> "wt": 3.57,
#> "qsec": 14.6,
#> "vs": 0,
#> "am": 1,
#> "gear": 5,
#> "carb": 8
#> }
#> ],
#> [
#> 32,
#> {
#> "mpg": 21.4,
#> "cyl": 4,
#> "disp": 121,
#> "hp": 109,
#> "drat": 4.11,
#> "wt": 2.78,
#> "qsec": 18.6,
#> "vs": 1,
#> "am": 1,
#> "gear": 4,
#> "carb": 2
#> }
#> ]
#> ]
#> }
#>