Advertisement

JavaScript Object Notation

  • Deborah Nolan
  • Duncan Temple Lang
Chapter
Part of the Use R! book series (USE R)

Abstract

In this chapter, we describe the JSON format and then the fromJSON() and toJSON() functions to both read and create JSON content. Because JSON is so simple and there are few supporting technologies for JSON, there are not many details that we need to examine before being able to work with JSON effectively. As a result, we spend a significant part of this chapter illustrating how we work with JSON in different contexts. These display other technologies that use JSON which are interesting in their own right. We look at reading JSON data from both Web services and from local files. We also show how to serialize data from R to JSON in order to add it to interactive HTML and SVG documents. Finally, we explore the ElasticSearch text search engine and how we use JSON to both insert documents into the engine and receive query results from the engine.

Keywords

Character Vector Numeric Vector Apache Software Foundation Associative Array Primitive Data Type 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [1]
    10gen, Inc. The MongoDB NoSQL database. http://www.mongodb.org, 2011.
  2. [2]
    Daniel Adler. rdyncall: Improved foreign function interface (FFI) and dynamic bindings to C libraries (e.g., OpenGL). http://cran.r-project.org/package=rdyncall, 2012. R package version 0.7.5.
  3. [3]
    Apache Software Foundation. Apache Lucene: Open-source search software. http://lucene.apache.org, 2011.
  4. [4]
    Apache Software Foundation. Spam Assassin: A spam filter that can be used on a wide variety of email systems. http://spamassassin.apache.org, 2011.
  5. [5]
    Shay Banon. Elasticsearch: An open source, distributed, RESTful search engine. http://www.elasticsearch.org, 2011.
  6. [6]
    Gabriel Becker and Duncan Temple Lang. RBrowserPlugin: R in the Web browser. https://github.com/gmbecker/RFirefox, 2012. R package version 0.1-5.
  7. [7]
    Alex Couture-Beil. rjson: Converts R object into JSON and vice-versa. http://cran.rproject.org/web/packages/rjson/, 2011. R package version 0.2.6.
  8. [8]
    Douglas Crockford. JavaScript: The Good Parts. O’Reilly Media, Inc., Sebastopol, CA, 2008.Google Scholar
  9. [9]
    Dirk Eddelbuettel and Romain Francois. Rcpp: Seamless R and C++ integration. http://cran.r-project.org/package=Rcpp, 2011. R package version 0.9.15.
  10. [10]
    Bryan English. JPath: A JavaScript class which provides an XPath -like querying ability to JSON objects. http://bluelinecity.com/software/jpath, 2011.
  11. [11]
    David Flanagan. JavaScript: The Definitive Guide. O’Reilly Media, Inc., Sebastopol, CA, 2006.Google Scholar
  12. [12]
    Markus Gesmann and Diego de Castillo. googleVis: Interface between R and the Google Visualisation API. http://cran.r-project.org/package=googleVis, 2011. R package version 0.2.13.
  13. [13]
    Stefan Goessner. JSON Path – XPath for JSON. http://goessner.net/articles/JsonPath/, 2011.
  14. [14]
    Google, Inc. Google News: A news aggregator service. http://news.google.com, 2011.
  15. [15]
    Google, Inc. Google Visualization API reference. https://developers.google.com/chart/interactive/docs/reference, 2012.
  16. [16]
    Lars Magne Ingebrigtsen. Gmane: A public mailing list archive. http://gmane.org, 2011.
  17. [17]
    JSON Advocate Group. Introducing JSON: A lightweight data-interchange format. http://www.json.org/, 2006.
  18. [18]
    Kiva Organization. Kiva: Loans that change lives. http://www.kiva.org/, 2011.
  19. [19]
    Gerald Lindsly. rmongodb: R-MongoDB driver. http://cran.r-project.org/package=rmongodb, 2011. R package version 1.0.3.
  20. [20]
    Deborah Nolan and Duncan Temple Lang. SVGAnnotation: Tools for post-processing SVG plots created in R. http://www.omegahat.org/SVGAnnotation, 2011. R package version 0.9.
  21. [21]
    Jeroen Ooms. opencpu.encode: Encodes R objects to a standardized JSON format. http://cran.r-project.org/web/packages/opencpu.encode/, 2012. R package version 0.22.
  22. [22]
    R Core Team. Writing R Extensions. Vienna, Austria, 2012. http://cran.r-project.org/doc/manuals/r-release/R-exts.html.
  23. [23]
    Duncan Temple Lang. RGCCTranslationUnit: R interface to GCC source code information. http://www.omegahat.org/RGCCTranslationUnit, 2009. R package version 0.4-0.
  24. [24]
    Duncan Temple Lang. RJSONIO: Serialize R objects to JSON (JavaScript Object Notation). http://www.omegahat.org/RJSONIO, 2011. R package version 0.95.
  25. [25]
    The JSON Schema Community. JSON schema: A JSON-based format for describing JSON data. http://json-schema.org/, 2011.
  26. [26]
    The New York Times Company. The Times Developer Network: An API clearinghouse and community. http://developer.nytimes.com/docs/campaign_finance_api/campaign_finance_api_examples, 2012.
  27. [27]
    W3Schools, Inc. JSON tutorial. http://www.w3schools.com/json/default.asp, 2012.
  28. [28]
    Jonathan Wallace. The libjson project: A JSON reader and writer. http://sourceforge.net/projects/libjson/, 2012.

Copyright information

© Springer Science+Business Media New York 2014

Authors and Affiliations

  • Deborah Nolan
    • 1
  • Duncan Temple Lang
    • 2
  1. 1.Department of StatisticsUniversity of CaliforniaBerkeleyUSA
  2. 2.Department of StatisticsUniversity of CaliforniaDavisUSA

Personalised recommendations