0

I have a file, json file, I want to access all the elements inside it. How do I do it. File structure is like this

  {
  "Sessions": [
    {
      "AppVersion": "2.4.0", 
      "Connectivity": "Cellular", 
      "Device": "iPhone 6 Plus", 
      "DeviceType": "Phone", 
      "Duration": 958616, 
      "Id": "591e3580e3f5fb2ade29f4d8", 
      "Location": {
        "Country": "US", 
        "Description": "Cleveland Texas"
      }, 
      "OSVersion": "10.3.1", 
      "Platform": "iOS", 
      "Screens": [
        {
          "Actions": [], 
          "Gestures": [], 
          "Name": "LoginPage", 
          "StartTime": 0
        }, 
        {
          "Actions": [
            {
              "Description": "Image", 
              "Index": "2.23", 
              "Time": 46179, 
              "Type": "ButtonTap"
            }, 
            {
              "Description": "Image", 
              "Index": "2.23", 
              "Time": 46735, 
              "Type": "ButtonTap"
            }, ]}

......100 elements

I can only access Sessions, not inside of it, like if I want to access "Time", how that can be done?

Jaap
  • 81,064
  • 34
  • 182
  • 193

1 Answers1

0

try package jsonlite

https://cran.r-project.org/web/packages/jsonlite/vignettes/json-aaquickstart.html

  library(jsonlite)
  myfile <- fromJSON("mydata.json", flatten=TRUE)

Also see Importing data from a JSON file into R

Ajay Ohri
  • 3,382
  • 3
  • 30
  • 60
  • Ok, so what it did is, it made the table look simple. Thanks. Now I can see a sophisticated table, and can access the columns via data.frame. Just a problem is occurring, when I see full table, it looks fine, but when I try to extract a column from it, it is not displaying nicely. Let me know if you have some solution for it. –  Jun 22 '17 at 10:09
  • myfile$columnname would give you the column – Ajay Ohri Jun 22 '17 at 11:21
  • copy and paste some of the column , table and after – Ajay Ohri Jun 22 '17 at 11:23