I want to create JSON data using R's jsonlite package to load to DynamoDB using Python. I want the data to be in the structure shown below. How can I create this in R? I tried creating a data frame where one of the columns is a list and change the data frame to json but the result is not in the required format. I also tried a converting a list which contains a list, but the structure of the output json is not what I want.
[
{
"ID": 100,
"title": "aa",
"more": {
"interesting":"yes",
"new":"no",
"original":"yes"
}
},
{
"ID": 110,
"title": "bb",
"more": {
"interesting":"no",
"new":"yes",
"original":"yes"
}
},
{
"ID": 200,
"title": "cc",
"more": {
"interesting":"yes",
"new":"yes",
"original":"no"
}
}
]
Here is my sample data and what I tried:
library(jsonlite)
ID=c(100,110,200)
Title=c("aa","bb","cc")
more=I(list(Interesting=c("yes","no","yes"),new=c("no","yes","yes"),original=c("yes","yes","no")))
a=list(ID=ID,Title=Title,more=more)
a=toJSON(a)
write(a,"temp.json") # this does not give the structure I want