diff --git a/README.md b/README.md index 7fcda52..da77e2c 100644 --- a/README.md +++ b/README.md @@ -96,114 +96,6 @@ read_json_str(str) #> 3 4.7 3.2 1.3 0.2 setosa ``` -# Parsing differences compared to `{jsonlite}` - -## 3-d arrays are parsed as multiple 2-d matrices and combined - -In `{yyjsonr}` the order in which elements in an array are serialized to -JSON correspond to an array of row-major matrices in human-readable -order. - -`{jsonlite}` does things differently. - -The array formats are internally consistent within each package, but not -cross-compatible between them i.e. you cannot serialize an array in -`{yyjsonr}` and re-create it exactly using `{jsonlite}`. - -``` r -# A simple 3D array -mat <- array(1:12, dim = c(2,3,2)) -mat -#> , , 1 -#> -#> [,1] [,2] [,3] -#> [1,] 1 3 5 -#> [2,] 2 4 6 -#> -#> , , 2 -#> -#> [,1] [,2] [,3] -#> [1,] 7 9 11 -#> [2,] 8 10 12 -``` - -``` r -# jsonlite's serialization of matrices is internally consistent and re-parses -# to the initial matrix. -str <- jsonlite::toJSON(mat, pretty = TRUE) -cat(str) -#> [ -#> [ -#> [1, 7], -#> [3, 9], -#> [5, 11] -#> ], -#> [ -#> [2, 8], -#> [4, 10], -#> [6, 12] -#> ] -#> ] -jsonlite::fromJSON(str) -#> , , 1 -#> -#> [,1] [,2] [,3] -#> [1,] 1 3 5 -#> [2,] 2 4 6 -#> -#> , , 2 -#> -#> [,1] [,2] [,3] -#> [1,] 7 9 11 -#> [2,] 8 10 12 -``` - -``` r -# yyjsonr's serialization of matrices is internally consistent and re-parses -# to the initial matrix. -# But note that it is *different* to what jsonlite does. -str <- yyjsonr::write_json_str(mat, pretty = TRUE) -cat(str) -#> [ -#> [ -#> [ -#> 1, -#> 3, -#> 5 -#> ], -#> [ -#> 2, -#> 4, -#> 6 -#> ] -#> ], -#> [ -#> [ -#> 7, -#> 9, -#> 11 -#> ], -#> [ -#> 8, -#> 10, -#> 12 -#> ] -#> ] -#> ] -yyjsonr::read_json_str(str) -#> , , 1 -#> -#> [,1] [,2] [,3] -#> [1,] 1 3 5 -#> [2,] 2 4 6 -#> -#> , , 2 -#> -#> [,1] [,2] [,3] -#> [1,] 7 9 11 -#> [2,] 8 10 12 -``` - ## Future - Re-introduce NDJSON support @@ -218,7 +110,8 @@ yyjsonr::read_json_str(str) ## Limitations - Some datatypes not currently supported. Please file an issue on GitHub - if these types are critical for yoy: + if these types are critical for you. Providing test cases also + appreciated!: - Complex numbers - POSIXlt - Matrices of POSIXct / Date diff --git a/man/benchmark/benchmarks.Rmd b/man/benchmark/benchmarks.Rmd index 9003c12..416285f 100644 --- a/man/benchmark/benchmarks.Rmd +++ b/man/benchmark/benchmarks.Rmd @@ -283,7 +283,7 @@ ggplot(plot_df) + facet_wrap(~benchmark, scales = 'free_y', ncol = 3) + theme_bw() + theme(legend.position = 'none') + - scale_fill_manual(values = c(rep(grey(0.5), 3), 'dodgerblue3')) + + scale_fill_manual(values = c(rep(grey(0.5), 2), 'dodgerblue3')) + geom_hline(yintercept = 1, color = 'red', alpha = 0.5, linetype = 2) + labs( x = NULL, diff --git a/man/figures/benchmark-summary.png b/man/figures/benchmark-summary.png index 92d8e13..233d29a 100644 Binary files a/man/figures/benchmark-summary.png and b/man/figures/benchmark-summary.png differ