-1

I want to import my JSON file into R. Installed the packages. This is what I tried ->

library(rjson)
JsonData <- fromJson(file= "<filename.json>")

Also tried the file path and jsonlite package. I get this error --->

Error in file(con,"r"): can not open the connection. In addition: Warning message: cannot open file '': invalid argument

I have set up every thing right, but its just wont work. I also tried other available options too!

Noel Harris
  • 131
  • 1
  • 13

1 Answers1

0

JsonData <- fromJson(file= "<filename.json>")

should be

JsonData <- fromJSON(file= "filename.json")

Two things: you should change fromJson to fromJSON (remember, R is case-sensitive), and you should remove the greater-than and less-than symbols (< and >) in your file path

stevec
  • 41,291
  • 27
  • 223
  • 311
  • thank you for the answer. I still get an error --> Error in fromJSON(file= "BMVI_daten_BBA_Alle_Tech.json") unexpected chatacter '' – Noel Harris Jul 25 '18 at 09:41
  • @NatalieSablowski interesting. Can you paste your JSON [here](https://codebeautify.org/jsonvalidator) (it will validate whether or not it contains errors in JSON syntax) – stevec Jul 25 '18 at 09:48
  • it wont load. There is an error. I converted this json from an csv online ( but here https://jsonformatter.curiousconcept.com it says that the json is just right - @user5783745 – Noel Harris Jul 25 '18 at 11:01