I have a data frame as follows:
item <- c(rep.int("Item ID 1", 4), rep.int("Item ID 2", 3))
links <- c("A", "B", "C", "D", "A", "E", "F")
df <- as.data.frame(cbind(item, links))
I am looking to convert this to a json
with multiple values for each links
key (is that the correct term?)
Expected JSON
{
"items": [
{
"type": "item",
"name": "Item ID 1",
"links": [
"A",
"B",
"C",
"D"
]
},
{
"type": "item",
"name": "Item ID 2",
"links": [
"A",
"E",
"F"
]
}
}
This is needed for a d3.js
visualization but I haven't been able to convert it so far.