JSON stands for JavaScript Object Notation. It is a lightweight format for storing and transporting data. JSON file is often used when data is sent from a server to a web page. It often stores data as text in human readable format. R can read JSON file using the rjson package.

Install rjson Package

To install rjson package use the following command:

Create a JSON File

Copy the following code into notepad or any other text editor and save this file with a .json extension.

Read the JSON File

fromJSON() function is used to read the JSON file in R. It is stored as a list in R.




[1] “1” “2” “3” “4” “5”


[1] “Nikita” “Deep”   “Aman”   “Nidhi”  “Sonu” 


[1] “50000” “20000” “25000” “23000” “30000”


[1] “1/1/2018”   “9/23/2014”  “11/15/2017” “5/11/2015”  “3/27/2019”


[1] “IT”         “Operations” “IT”         “HR”         “Finance”

Convert JSON to a Data Frame

We can convert the JSON data which is extracted from fromJson() function into the form of data frame. For this R provides a function i.e. as.data.frame() function.





Pin It on Pinterest

Share This