Reading a json file could be possible with this commands:
library(jsonlite)
json_text <- readLines("tect.json", warn = FALSE, encoding = "UTF-8")
Parse the JSON data
json_data <- fromJSON(txt = paste(json_text, collapse = ""))
in a format of data inside the tect.json file like this:
[
{
"id": 1,
"name": "Apple",
"color": "red",
"price": 0.99
},
{
"id": 2,
"name": "Banana",
"color": "yellow",
"price": 0.5
},
{
"id": 3,
"name": "Orange",
"color": "orange",
"price": 0.75
}
]
However if the tech.json has this format how is it possible to read it as a json file and convert it to a dataframe?
{"id": 1, "name": "Apple", "color": "red", "price": 0.99 }
{"id": 2, "name": "Banana", "color": "yellow", "price": 0.5 }
{"id": 3, "name": "Orange", "color": "orange", "price": 0.75 }
If I try the option at the start to read this file I receive an error like this:
Error: parse error: trailing garbage nge":"
How is it possible to read this file?