Web Scraping R Data From JSON (R jsonlite)

Second article in a series covering scraping data from the web into R; Part I is here and we give some suggestions on potential projects here.

JSON has emerged as one of the common standards for sharing data on the web, particularly data that may be consumed by front-end JavaScript applications. JSON (Javascript Object Notation) is a key:value format which provides the reader with a high degree of context about what a value means. The key-value structure can be nested, permitting data packets like the following:

So, if you’re wondering how to access json…. or better yet, convert json to dataframe elements…

R jsonlite – reading json in r

Several libraries have emerged for R users that enable you to easily process and digest JSON data. Here is an example from one of these libraries, jsonlite, which is a fork of another leading library RJSONIO. We selected this library due its relative ease of use.

Since jsonlite doesn’t come as part of the r standard libraries, we must install it: