Adds indentiation to a JSON string

pretty_json(json, ...)

Arguments

json

string of JSON

...

other argments passed to to_json

Examples


df <- data.frame(id = 1:10, val = rnorm(10))
js <- to_json( df )
pretty_json(js)
#> [
#>     {
#>         "id": 1,
#>         "val": -0.7131482505093049
#>     },
#>     {
#>         "id": 2,
#>         "val": 1.882374377029833
#>     },
#>     {
#>         "id": 3,
#>         "val": 1.9403227345897385
#>     },
#>     {
#>         "id": 4,
#>         "val": -0.20585074611809604
#>     },
#>     {
#>         "id": 5,
#>         "val": -0.10197584747950264
#>     },
#>     {
#>         "id": 6,
#>         "val": 0.393169751038492
#>     },
#>     {
#>         "id": 7,
#>         "val": -0.8436802810553545
#>     },
#>     {
#>         "id": 8,
#>         "val": 0.8412175457621063
#>     },
#>     {
#>         "id": 9,
#>         "val": 0.35481328194417346
#>     },
#>     {
#>         "id": 10,
#>         "val": -1.103750332014542
#>     }
#> ] 

## can also use directly on an R object
pretty_json( df )
#> [
#>     {
#>         "id": 1,
#>         "val": -0.7131482505093049
#>     },
#>     {
#>         "id": 2,
#>         "val": 1.882374377029833
#>     },
#>     {
#>         "id": 3,
#>         "val": 1.9403227345897385
#>     },
#>     {
#>         "id": 4,
#>         "val": -0.20585074611809604
#>     },
#>     {
#>         "id": 5,
#>         "val": -0.10197584747950264
#>     },
#>     {
#>         "id": 6,
#>         "val": 0.393169751038492
#>     },
#>     {
#>         "id": 7,
#>         "val": -0.8436802810553545
#>     },
#>     {
#>         "id": 8,
#>         "val": 0.8412175457621063
#>     },
#>     {
#>         "id": 9,
#>         "val": 0.35481328194417346
#>     },
#>     {
#>         "id": 10,
#>         "val": -1.103750332014542
#>     }
#> ]