I have a log file that look like this. This is a text document that looks like:
Id,Date,Level,Message
35054,2016-06-17 19:29:43 +0000,INFO,"{
""id"": -2,
""ipAddress"": ""100.100.100.100"",
""howYouHearAboutUs"": null,
""isInterestedInOffer"": true,
""incomeRange"": 60000,
""isEmailConfirmed"": false
}"
35055,2016-06-17 19:36:38 +0000,INFO,"{
""id"": -1,
""firstName"": ""John"",
""lastName"": ""Smith"",
""email"": ""john.smith@gmail.com"",
""city"": ""Smalltown"",
""incomeRange"": 1,
""birthDate"": ""1999-12-10T05:00:00Z"",
""password"": ""*********"",
""agreeToTermsOfUse"": true,
""howYouHearAboutUs"": ""Radio"",
""isInterestedInOffer"": false
}"
35059,2016-07-19 19:52:08 +0000,INFO,"{
""id"": -3,
""visitUrl"": ""https://www.website.com/?purpose=X"",
""ipAddress"": ""100.200.300.400"",
""howYouHearAboutUs"": null,
""isInterestedInOffer"": true,
""incomeRange"": 100000,
""isEmailConfirmed"": true,
""isIdentityConfirmed"": false,
""agreeToTermsOfUse"": true,
""validationResults"": null
}"
I'm trying to parse the JSON in the Message
column by:
library(readr)
library(jsonlite)
df <- read_csv("log_file_from_above.csv")
fromJSON(as.character(df$Message))
But, I'm hitting the following error:
Error: parse error: trailing garbage
"isEmailConfirmed": false } { "id": -1, "firstName":
(right here) ------^
How can I get rid of the "trailing garbage"?