I have a multi-level JSON file like so:
{
"key1":1,
"key2":"a"
}
{
"key1":2,
"key2":"b"
}
My goal is to convert this file into a data frame
with two columns and two rows like so:
ml_df
key1 key2
1 1 a
2 2 b
At the moment, I have:
library(rjson)
ml_json <- fromJSON(file = "multi_level.json")
ml_df_fail <- as.data.frame(ml_json)
The problem is that ml_df_fail
has only one row with two columns like so:
ml_df_fail
key1 key2
1 1 a
How to read multi-level JSON files in R?