how to store data frame in file


First of all, a word of warning: you should never provide authentication information in code you share as this might be sensitive information that could lead to issues if it falls into the wrong hands :slight_smile:
I know you did this to help us recreate the issue, but next time try to see if you can generate the same issue without having to share authentication credentials. A very nice start guide is here

To the question at hand now:
JSON is not the same data structure as a table and can have nested lists of data which are not possible in csv. Sometimes you can easily convert if JSON does not have nested data, but in your case it is. Look at the "result.mailingAddress", "result.regionalbereich", ... they are nested data frames within a data frame. So you cannot simply convert this to a regular data frame. You can extract parts or remove them, but flattening everything into one giant table will be impossible or even if possible, will generate a massive table with a lot of repeating values.

Best way is to save the json as a json :slight_smile: Then you can load it back whenever needed.


h <- new_handle()
handle_setheaders(h,Authorization = "Bearer 60ff659020cbdccfb2b7aacaa03af4f7")
url <- ""
res <- curl_fetch_memory(url,h)
myjsondata <- rawToChar(res$content)
myjsondata <- fromJSON(prettify(myjsondata))

#Write the json
write_json(myjsondata, "allStationTODAYNOV.json", pretty = T)

#Read the json
test = read_json("allStationTODAYNOV.json", simplifyVector = T)


  • pretty = T makes sure the JSON is saved in a pretty more readable multi-line format with indentation instead of just one giant row of text
  • simplifyVector = T will try and simplify JSON files when read in by simplifying nested lists into vectors and data frames

Hope this helps,