# Function stored as text
jsonlite::toJSON(
list(fun = "function(x) {console.log(x);}"),
auto_unbox = TRUE, json_verbatim = TRUE
)
# Function stored as raw JS object
jsonlite::toJSON(
list(fun = as_json("function(x) {console.log(x);}")),
auto_unbox = TRUE, json_verbatim = TRUE
)
Run the code above in your browser using DataLab