Query, Pivot, Patch, and Validate 'JSON' and 'NDJSON'

Functions to query (filter or transform), pivot (convert from array-of-objects to object-of-arrays, for easy import as 'R' data frame), search, patch (edit), and validate (against 'JSON Schema') 'JSON' and 'NDJSON' strings, files, or URLs. Query and pivot support 'JSONpointer', 'JSONpath' or 'JMESpath' expressions. The implementation uses the 'jsoncons' < https://danielaparker.github.io/jsoncons/> header-only library; the library is easily linked to other packages for direct access to 'C++' functionality not implemented here.


rjsoncons

CRAN status CRAN downloads

This package provides functions to query (filter or transform), pivot (convert from array-of-objects to object-of-arrays, for easy import as 'R' data frame), search, patch (edit), and validate (against JSON Schema) 'JSON' and 'NDJSON' strings, files, or URLs. Query and pivot support JSONpointer, JSONpath or JMESpath expressions. The implementation uses the jsoncons header-only library; the library is easily linked to other packages for direct access to 'C++' functionality not implemented here.

Installation and loading

Install the released package version from CRAN

install.packages("rjsoncons", repos = "https://CRAN.R-project.org")

Install the development version with

if (!requireNamespace("remotes", quiety = TRUE))
    install.packages("remotes", repos = "https://CRAN.R-project.org")
remotes::install_github("mtmorgan/rjsoncons")

Attach the installed package to your R session with

library(rjsoncons)

Use cases

The introductory vignette outlines common use cases, including:

  • Filter large JSON or NDJSON documents to extract records or elements of interest.
  • Extract deeply nested elements.
  • Transform data for more direct incorporation in R data structures.
  • 'Patch' JSON strings programmatically, e.g., to update HTTP request payloads.
  • Validate JSON documents against JSON schemas

The jsoncons C++ header-only library is a very useful starting point for advanced JSON manipulation. The vignette outlines how rjsoncons can be used by other R packages wishing to access the C++ library.

Next steps

See the introductory vignette for additional details.

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("rjsoncons")

1.3.3 by Martin Morgan, 4 months ago


https://mtmorgan.github.io/rjsoncons/


Report a bug at https://github.com/mtmorgan/rjsoncons/issues


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


Authors: Martin Morgan [aut, cre] (ORCID: , Marcel Ramos [aut] , Daniel Parker [aut, cph] (jsoncons C++ library maintainer)


Documentation:   PDF Manual  


BSL-1.0 license


Imports cli, tibble

Suggests jsonlite, tinytest, BiocStyle, knitr, rmarkdown

Linking to cpp11, cli


See at CRAN