Använd gsub()
jsontest <- gsub(pattern = '^\[', replacement = "", x = jsontest)
jsontest <- gsub(pattern = '\]$', replacement = "", x = jsontest)
Resultat :
{
"section_id": {},
"name": "name1",
"slug": "slug1"
},
{
"section_id": {},
"name": "name2",
"slug": "slug2"
},
{
"section_id": {},
"name": "name3",
"slug": "slug3",
"categories": [
{
"section_id": {},
"name": "name31",
"slug": "slug31"
},
{
"section_id": {},
"name": "name32",
"slug": "slug32"
}
]
}
Fortfarande json
klass :
> class(jsontest)
[1] "json"
Men det tomma utrymmet kanske kan orsaka problem.