inst/doc/jsonlite-comparison.R

## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(yyjsonr)

## -----------------------------------------------------------------------------
# A simple 3D array 
mat <- array(1:12, dim = c(2,3,2))
mat

## -----------------------------------------------------------------------------
# jsonlite's serialization of matrices is internally consistent and re-parses
# to the initial matrix.
str <- jsonlite::toJSON(mat, pretty = TRUE)
cat(str)
jsonlite::fromJSON(str)

## -----------------------------------------------------------------------------
# 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)
yyjsonr::read_json_str(str)

Try the yyjsonr package in your browser

Any scripts or data that you put into this service are public.

yyjsonr documentation built on May 29, 2024, 3:01 a.m.