I have a named list in R that I want to convert to JSON (in order to send it as a document in MongoDB)
L=list(A=1,B=as.POSIXct("1990-01-01"))
If I do simply toJSON, the date format of the second element is lost (it is converted to numeric).
> cat(toJSON(L))
{
"A": 1,
"B": 6.3115e+08
}
How can I can obtain:
{
"A": 1,
"B": new Date('1990-01-01')
}
?
I have not found anything like this in the documentation of JSONIO package.