R version 4.5.0 alpha (2025-03-23 r88038 ucrt) Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(RJSONIO) > > toJSON(list(1, 2, list(1, NA))) [1] "[\n 1,\n 2,\n[\n 1,\nnull \n] \n]" > > toJSON(list(1, 2, list(NA))) # collapses the sub-list into the main vector. [1] "[\n 1,\n 2,\n[\n null \n] \n]" > > > e = new.env(); e$a = 1:10; e$bc = letters[1:3] > cat(toJSON(e, pretty = TRUE)) { "a" : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], "bc" : [ "a", "b", "c" ] }> > > a = list(x=1, y=character(0)) > fromJSON( toJSON( a ) ) $x [1] 1 $y list() > a = list(x=1, y=character(0), b = 1) > fromJSON( toJSON( a ) ) $x [1] 1 $y list() $b [1] 1 > > > a = list(x = vector(), y = 123, z = "allo") > fromJSON(toJSON(a)) $x list() $y [1] 123 $z [1] "allo" > > > > proc.time() user system elapsed 0.23 0.09 0.54