A Robust, High Performance JSON Parser and Generator for R

A fast JSON parser and generator optimized for statistical data and the web. Started out as a fork of 'RJSONIO', but has been completely rewritten in recent versions. The package offers flexible, robust, high performance tools for working with JSON in R and is particularly powerful for building pipelines and interacting with a web API. The implementation is based on the mapping described in the vignette (Ooms, 2014). In addition to converting JSON data from/to R objects, 'jsonlite' contains functions to stream, validate, and prettify JSON data. The unit tests included with the package verify that all edge cases are encoded and decoded consistently for use with dynamic data in systems and applications.


News

1.1

  • stream_in now passes ... arguments to fromJSON as documented
  • Force ANSI_STDIO on Windows to fix -pedantic compiler warning
  • Close connection even if opening fails. Fixes #145
  • validate() now includes an 'offset' attribute indicating at which byte the error occured
  • Refresh some example tokes for vignettes

1.0

  • Fix always_decimal for non-whole numbres which get rounded to whole numbers
  • Rename and export base64 encoder/decoder
  • Fix compiler warning on Windows: don't redefine isnan() and isinf()
  • Changed targed in Makevars to libstatyajl.a to prevent conflict with system libyajl
  • Bump to 1.0 because this package is basically done

0.9.22

  • Fix for side effects of 'always_decimal' on Date and POSIXt integer encoding
  • Fixed a small memory leak in the push parser (fromJSON.connection)
  • Cleaned up Makevars
  • Replace base64 encoder/decoder to be in-memory
  • Special case toJSON(NULL, null = "null") now returns "null"

0.9.21

  • Add 'always_decimal' argument in toJSON for real number notation in whole number doubles.

0.9.20

  • Performance optimization for toJSON on matrices and arrays
  • Tweak for unboxed POSIXt = "mongo" queries

0.9.19

  • Remove the View() workaround because it causes issues in RStudio and because the bug in utils::View has been fixed in R-patched.

0.9.18

  • Removed support for the archived int64 package. Use bit64 instead.
  • The stream_in function now skips over blank lines
  • Remove workaround for View() in rstudio
  • fromJSON now sets an 'Accept' request header for URLs.

0.9.17

  • Fix for 1 dimensional array objects
  • Fix for unnamed data frame
  • Fix for duplicate _row fields
  • The 'unbox' function now accepts classed scalars such as dates
  • Ignore BOM with warning in push parser

0.9.16

  • Performance optimizations in asJSON.data.frame by avoiding apply()
  • Prettifying is now done by default in R (thanks to Yihui Xie)
  • Add json_verbatim option to insert verbatim json
  • Improve verbose output of streaming functions

0.9.15

  • Replaced RCurl dependency with the new curl package.
  • Added push parser for more efficient parsing from connection interfaces (e.g. files or urls).
  • The toMongo function has been removed. Use stream_out instead.
  • The View function will not be exposed in recent versions of rstudio that supported nested data natively.
  • Add hidden bigint_as_char argument in fromJSON
  • Fixed a memory leak in fromJSON.
  • I() forces boxing of a scalar when 'auto_unbox = TRUE' for RJSONIO compatibility.
  • toJSON now supports 'keep_vec_names=TRUE' will mimic RJSONIO legacy behavior.
  • toJSON now supports 'time_format' argument to customize formatting of POSIXt strings.

0.9.14

  • Change license to MIT (for GPL2 compatibility).
  • Add support for digits = I(n) to use significant precision.
  • When 'pretty' in toJSON is numeric, it specifies the number of spaces to indent.
  • Bug fix in validate() related to ScalarLogical
  • Add support for dataframe = "values"
  • Byte-order-marks are now ignored as suggested by rfc7159
  • Add support for integer64 class (bit64 package)

0.9.13

  • Ported some number formatting to C
  • Fix when http server gives no content-type header
  • Prevent auto unboxing within a matrix
  • Assume UTF8 but fall back on native encoding for files and urls in fromJSON
  • Fix for 32 bit windows XP.

0.9.12

  • New JSON parser based on yajl. Some changes:
    • smaller and faster than libjson
    • better error messages
    • automatic validation
    • native \uXXXX unicode parsing
    • integer parsing
    • uses spaces intead of tabs for prettify
  • Other functions ported to C: collapse_object, null_to_na, is_recordlist, is_scalarlist
  • Expose 'flatten' function
  • Row names are encoded as "_row" instead of "$row"
  • Start with streaming functions
  • Some internal changes to support BSON/MongoDB

0.9.11

  • Added toJSON null argument
  • Fix bug in prettify object name escaping
  • Use C code for escaping and collapsing vectors
  • Several performance enhancements in fromJSON/simplify code
  • The auto_unbox argument is ignored for dataframes when dataframe="column"

0.9.10

  • Add support for escaped (hexadecimal) unicode characters in fromJSON(unicode = TRUE)
  • Exporting a wrapper for View() that flattens nested data frames
  • Add print method for scalar (unbox)

0.9.9

  • Fix bug where 'flatten' argument wasn't passed down
  • Make asJSON automatically unname any named lists within a data frame
  • fromJSON(url) now sets Accept header
  • Increase default to digits=4 in toJSON

0.9.8

  • Remove whitespace from default output of toJSON
  • Split vignette in 3 documents
  • Add support for simplifyMatrix within a data frame
  • Add class "json" output of toJSON, simplify, minify
  • Add print method for json
  • Cleaned up unit tests
  • Workaround for SSL handshake issues in https downloads
  • Raise warnings for SSL or Content-Type abnormalities

0.9.7

  • formally expose 'force' argument in toJSON
  • formally expose 'flatten' argument in fromJSON
  • fix bug in simplifyDataframe
  • fix in rlibjson code that converted empty array to AsIs object
  • auto coerse mongo type dates in fromJSON

0.9.6

  • toJSON gains argument auto_unbox
  • Minor fixes

0.9.5

  • Never raise error in toJSON when force=true
  • Fix typo in line 2 of JSONDefs/GNU_C.h (GUN -> GNU)
  • Run unit tests during R CMD check
  • Update vignette

0.9.4

  • Added minify function
  • Added unbox function
  • Fixed bug where toJSON 'force' argument wasn't passed down
  • Removed -DJSON_VALIDATE -DJSON_STREAM=1 from Makevars.in (already in JSONoptions.h)

0.9.3

  • Changes by Prof Ripley for Solaris/CRAN

0.9.2

  • Update libjson to 7.6.1 (fixes bug in the validator)
  • Generalized toJSON method 'matrix' to 'array' to work for higher dimensions.
  • Add option to encode matrix either row-major or column-major.
  • Set default SSL version to 3 for fromJSON("https://...")

0.9.1

  • Major performance improvements for toJSON.data.frame

0.9.0

  • Initial release

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

1.4 by Jeroen Ooms, 21 days ago


https://arxiv.org/abs/1403.2805, https://www.opencpu.org/posts/jsonlite-a-smarter-json-encoder


Report a bug at http://github.com/jeroen/jsonlite/issues


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


Authors: Jeroen Ooms, Duncan Temple Lang, Lloyd Hilaiel


Documentation:   PDF Manual  


Task views: Web Technologies and Services


MIT + file LICENSE license


Depends on methods

Suggests httr, curl, plyr, testthat, knitr, rmarkdown, R.rsp, sp


Imported by ALA4R, AWR.KMS, AWR.Kinesis, AutoDeskR, AzureML, BEQI2, BIOMASS, BoSSA, CytobankAPI, ECharts2Shiny, EcoGenetics, GADMTools, HARtools, HIBPwned, IMFData, LendingClub, MBTAr, OpenML, Quandl, RDataCanvas, RDota2, RGA, RInno, RMixpanel, RNeo4j, ROpenFIGI, ROpenWeatherMap, ROptimizely, RPresto, RPublica, RPushbullet, RSiteCatalyst, RSocrata, RStripe, RYandexTranslate, RZabbix, Rexperigen, Rga4gh, SACCR, SGP, SensusR, SigOptR, SmarterPoland, SnakeCharmR, SocialMediaMineR, V8, WikidataQueryServiceR, WikidataR, WikipediR, WufooR, XR, Zelig, ZeligChoice, ZeligEI, alterryx, analogsea, archivist.github, autovarCore, aws.ec2metadata, aws.polly, aws.ses, aws.sns, aws.sqs, backblazer, bea.R, bigrquery, binman, binomen, biomartr, blscrapeR, bold, broman, cablecuttr, captr, cbsodataR, ccafs, cdcfluview, censys, ckanr, clarifai, colourlovers, comtradr, configr, covr, cranlogs, crminer, crosstalk, crunch, daff, dagitty, dataonderivatives, dataone, datarobot, ddeploy, devtools, diezeit, diffrprojectswidget, discgolf, distcomp, dlstats, docuSignr, dpmr, duckduckr, ecoengine, elastic, elasticsearchr, elevatr, emuR, enigma, epidata, etseed, europepmc, eurostat, exCon, fbRads, federalregister, fitbitScraper, flexdashboard, flora, franc, fulltext, gdns, gender, geoaxe, geojson, geojsonio, geojsonlint, geoparser, getMet, gfer, ggvis, gistr, gitgadget, githubinstall, gmailr, googleAnalyticsR, googleAuthR, googleCloudStorageR, googleComputeEngineR, googleVis, googlesheets, googleway, graphql, gym, h2o, hansard, highcharter, htmlwidgets, httpcache, httping, httptest, httr, hypothesisr, idbr, imfr, inegiR, jose, jsonld, jug, junr, kntnr, lawn, leafletCN, leafletR, lintr, livechatR, machina, manifestoR, mapr, melviewr, mnis, mongolite, monkeylearn, mregions, mscstexta4r, mscsweblm4r, mudata, nasadata, ndtv, neotoma, net.security, openadds, opencage, opencpu, originr, osrm, owmr, pageviews, pandocfilters, pangaear, pdfetch, pinnacle.API, pivottabler, placement, pleiades, plotly, plumber, polidata, postGIStools, protolite, qiitr, qualtRics, rAltmetric, rGoodData, rWBclimate, radiant.data, randNames, rapiclient, rbcb, rbhl, rbison, rbokeh, rcorpora, rcrossref, rdpla, rdrop2, rebird, rechonest, red, refimpact, rentrez, repijson, request, rerddap, reutils, rfml, rgbif, rgho, rgl, rhandsontable, ridigbio, riem, rif, rinat, rintrojs, ritis, rjsonapi, rjstat, rlist, rmarkdown, rnoaa, rnpn, roadoi, rodham, ropenaq, rorcid, rosetteApi, rotl, rplos, rredlist, rscorecard, rsnps, rstatscn, rsunlight, rtimes, rtweet, rtypeform, rvertnet, sbtools, seeclickfixr, servr, shiny, shinyHeatmaply, shinyWidgets, shinybootstrap2, shinyjqui, shinyjs, slackr, sofa, solrium, solvebio, sparklyr, spectrino, spocc, statsgrokse, stmBrowser, stmCorrViz, stplanr, taxize, telegram, threejs, tidyjson, tidyverse, timevis, trackeR, traits, trelliscope, trelloR, tubern, twilio, ubeR, urlshorteneR, vegalite, vegdata, visNetwork, vkR, wbstats, webchem, webshot, webutils, wellknown, whoami, wikipediatrend, wikitaxa, worrms, x.ent, yhatr, yummlyr.

Depended on by GAR, RFc, RGoogleAnalyticsPremium, RGoogleFit, RSauceLabs, RWildbook, TMDb, instaR, jSonarR, oec, rHealthDataGov, seleniumPipes.

Suggested by ChemoSpec, DT, DataExplorer, bigQueryR, cowsay, crul, curl, d3r, data.tree, dismo, finch, futile.logger, io, jqr, listviewer, metricsgraphics, networkD3, openssl, pollstR, qtlcharts, quantmod, rio, soilDB, sunburstR, sysfonts.


See at CRAN