У меня есть следующий код:
library(dplyr)
head(iris[c(1,5)], n = 3) %>%
mutate(qtc = "{smooth: 7}") %>%
jsonlite::toJSON(pretty = TRUE)
, который создает этот вывод:
[
{
"Sepal.Length": 5.1,
"Species": "setosa",
"qtc": "{smooth: 7}"
},
{
"Sepal.Length": 4.9,
"Species": "setosa",
"qtc": "{smooth: 7}"
},
{
"Sepal.Length": 4.7,
"Species": "setosa",
"qtc": "{smooth: 7}"
}
]
Обратите внимание, что для этой записи "qtc": "{smooth: 7}"
значение "{smooth: 7}"
находится в кавычках. Как я могу удалить эту цитату в моем коде. Желаемый результат:
[
{
"Sepal.Length": 5.1,
"Species": "setosa",
"qtc": {"smooth": 7}
},
{
"Sepal.Length": 4.9,
"Species": "setosa",
"qtc": {"smooth": 7}
},
{
"Sepal.Length": 4.7,
"Species": "setosa",
"qtc": {"smooth": 7}
}
]