library(xfun)
tojson(NULL)
tojson(1:10)
tojson(TRUE)
tojson(FALSE)
tojson(list(a = 1, b = list(c = 1:3, d = "abc")))
tojson(list(c("a", "b"), 1:5, TRUE, Sys.Date() + 1:3))
tojson(head(iris)) # each column is in an element
tojson(unname(head(iris))) # each row is in an element
tojson(matrix(1:12, 3))
# literal JS code
JS = function(x) structure(x, class = "JS_LITERAL")
tojson(list(a = 1:5, b = JS("function() {return true;}")))
Run the code above in your browser using DataLab