-2

everyone. I have data from Instagram using this request: https://www.instagram.com/netflix/?__a=1

  1. How can I read the JSON File?
  2. How do I convert JSON to a Data Frame in R or other applications?

Thank you very much!

r2evans
  • 141,215
  • 6
  • 77
  • 149
Adriana
  • 1
  • 1
  • 1
    Many R reading-functions take urls, perhaps `json <- readLines("https://...")`. Once you get there, use `jsonlite::fromJSON` to extract into a `list`. I won't go any further, since this is *nothing* like a simple 2D frame, too many nooks and crannies to be handled generically. At a *minimum* (and it's barely scraping by), you need to define how you expect this more than 5-nested list into a 2d frame, with expected output. It would be much better if you showed effort and code attempted. Please see https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Nov 04 '21 at 13:04

1 Answers1

0

To read the JSON it's as simple as this

library(jsonlite)
fromJSON("https://www.instagram.com/netflix/?__a=1")

Now turning it into a data.frame is a completely bespoke problem - JSON returns a key-value store, which can be very unique in it's 'shape'. Data.frames are typically rectangular (tabular) data, whereas key-value stores can be extremely unique in their strcuture. So TL;DR, you have to think about which parts of the list you keep, or how you manipulate it into a data.frame.

stevec
  • 41,291
  • 27
  • 223
  • 311