Serialize R Objects to JSON

Converts R objects to and from JavaScript Object Notation (JSON). The package provides a stable interface for reading JSON from strings, files, and connections, and for serializing common R objects, including vectors, lists, data frames, arrays, environments, and S4 objects. It also exposes parser handlers, callbacks, and S4 methods for applications that need customized JSON processing while preserving established RJSONIO behavior.


RJSONIO

CRAN status R-CMD-check pkgdown

RJSONIO converts R objects to and from JSON. It provides a stable API for serializing R vectors, lists, data frames, arrays, environments, and S4 objects, and for reading JSON from strings, files, and connections.

The package is maintained as a compatibility-first JSON implementation for R. Its main value is stable behavior for established R workflows, plus extension points such as parser handlers, callbacks, S4 methods, connection parsing, and custom serialization methods.

Installation

Install the CRAN release:

install.packages("RJSONIO")

Install the development version from GitHub:

install.packages("remotes")
remotes::install_github("YaoxiangLi/RJSONIO")

Quick Start

library(RJSONIO)

x <- list(
  id = 1,
  name = "RJSONIO",
  values = c(1, 2, 3),
  active = TRUE
)

json <- toJSON(x, pretty = TRUE)
cat(json)

fromJSON(json)

Validate JSON before parsing:

candidate <- toJSON(list(name = "RJSONIO", version = "2.0.5"))
isValidJSON(I(candidate))

Round-trip common R objects:

value <- list(a = 1, b = c(TRUE, FALSE), c = c("x", "y"))
identical(fromJSON(toJSON(value)), value)

When RJSONIO Fits

RJSONIO is a good fit when a project already depends on its parsing or serialization behavior, or when code needs callback-based parsing, S4/object serialization, or explicit control over JSON generation.

For new projects that mainly consume web APIs or tidy tabular JSON, compare the available R JSON packages and choose the one whose mapping and performance match the job. The package website includes a comparison-oriented benchmark article and examples of RJSONIO's customization points.

Compatibility

The unit test suite includes compatibility coverage for parsing, serialization, simplification modes, encodings, connections, edge cases, and string callbacks. Changes to existing behavior should be deliberate, tested, and described in NEWS.md.

Documentation

Development

Run the unit tests:

testthat::test_local()

Run a package check:

R CMD build RJSONIO
R CMD check --no-manual RJSONIO_2.0.5.tar.gz

Optional benchmark scripts are kept under benchmarks/. They are intended for local comparison work and are excluded from CRAN package builds.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("RJSONIO")

2.0.5 by Yaoxiang Li, 5 months ago


https://yaoxiangli.github.io/RJSONIO/, https://github.com/YaoxiangLi/RJSONIO


Report a bug at https://github.com/YaoxiangLi/RJSONIO/issues


Browse source code at https://github.com/cran/RJSONIO


Authors: Yaoxiang Li [aut, ctb, cre] (ORCID: , CRAN Team [aut] , Duncan Temple Lang [aut] (ORCID: , Jonathan Wallace [aut] (aka ninja9578 , author of included libjson sources)


Documentation:   PDF Manual  


BSD_3_clause + file LICENSE license


Imports methods

Suggests knitr, rmarkdown, testthat


Imported by CirceR, CropScapeR, DIZutils, FAOSTAT, LDAvis, PubChemR, RSDA, RedditExtractoR, SignacX, ajv, animint2, cmmr, gpboost, lipidmapsR, mitre, mojson, pubmed.mineR, rYoutheria, switchr, wilson.

Depended on by rbiouml, restimizeapi, ropensecretsapi.

Suggested by CodeDepends, exams, leaflet, tsmp.


See at CRAN