0

I have a dataframe where one of the columns is in jsonlines format (I think) and i can't manage to parse it and have tried a few different methods but end up with a trailing garbage error. Has anyone dealt with this before? I'm not sure why it isn't working.

library(tidyjson)
ff <- read.csv("https://raw.githubusercontent.com/HaydenSchilling/Example_code_and_data/master/testjson.csv")
ff

json_as_df <- ff %>% as.tbl_json(json.column = "EffortData")

results in:

Error: parse error: trailing garbage
                                    "{"BoatUnit": "BFM", "Electrofishi
                     (right here) ------^
Hayden
  • 107
  • 8
  • Looking at your raw data - `https://raw.githubusercontent.com/HaydenSchilling/Example_code_and_data/master/testjson.csv` - there appear to be extra quotes `"` around each string. This is probably your issue. – SymbolixAU May 24 '22 at 04:08
  • Thanks - good spotting. It seems load into R without these though. A previous version did load with all the extra quotation marks but i replaced all the doubles with single quotation marks and thought i had fixed that. `head(ff,1) EffortData 1 "{"BoatUnit": "BFM", "ElectrofishingDuration": 90, "SubmergedLight": false}" EffortPageLetter 1 A` – Hayden May 24 '22 at 04:23

0 Answers0