How might I parse and process JSON that already lives inside a data frame?
Sample data:
df <- data.frame(
id = c("x1", "x2"),
y = c('[{"Property":"94","Value":"Error"},{"Property":"C1","Value":"Found Match"},{"Property":"C2","Value":"Address Mismatch"}]', '[{"Property":"81","Value":"XYZ"},{"Property":"D1","Value":"Blah Blah"},{"Property":"Z2","Value":"Email Mismatch"}]')
)
I want to extract, format and separate the raw JSON in column y
into orderly columns, ideally with library(jsonlite)
.
Thanks in advance!
Using
jsonlite
and the tidyverse:or without
purrr
,or with just
dplyr
andjsonlite
,or with just base R and
jsonlite
,All return the same thing, so pick which makes the most sense to you.