I am basically trying to replicate the following json structure with jsonlite (any other package like rson would also be fine if it works better).
{
"classes": [1, 2, 3],
"ID": 0,
"Name": "Peter",
"Address": ""
}
My approach so far:
jsonlite::toJSON(list(classes=c(1, 2, 3), ID=0, Name="Peter", Address=""))
Which results in:
{"classes":[1,2,3],"ID":[0],"Name":["Peter"],"Address":[""]}
I think the problem is that everything in R is a vector, so even if I want just a single integer or string as an attribute it gets formatted as an array by enclosing it in [ ].