0

The figure below show is the csv file that contain dataset that have 7 variable, this dataset contain jason data at column number 3 which is order_list variable

enter image description here

My question is how to parse the jarson data in column 3 which is order_list variable of this dataset.

what i already do :

library(jsonlite)

df2 <- purrr::map(df$order_list, jsonlite::fromJSON)

str(df2)

enter image description here

the column 3 still remain as jason data.

  • Please don't paste data as images. It's not helpful to anybody hoping to answer your question - see https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – thelatemail Feb 24 '22 at 01:00

1 Answers1

0

As you saw, fromJSON returns a list. If you want it as a data.frame or tibble you can pipe its output into as.data.frame() or as_tibble(), from the tibble package.

jsonlite::fromJSON("https://us.api.iheart.com/api/v3/live-meta/stream/2501/currentTrackMeta?defaultMetadata=true")
rdelrossi
  • 1,114
  • 1
  • 7
  • 17
  • `fromJSON` returns a `data.frame` if possible - `jsoncars <- toJSON(mtcars, pretty=TRUE); fromJSON(jsoncars)` for example. This doesn't look like OP's issue as you can see in their result of `str()` that they are getting character vectors returned. – thelatemail Feb 24 '22 at 01:15
  • Ah, good point. Missed that in the image. – rdelrossi Feb 24 '22 at 01:31