fromJSON does not decode mongo coded dates.
Consider this code:
dt <- Sys.time()
dtl <- fromJSON(toJSON(unbox(dt),POSIXt="mongo"),FALSE)
Returns a list with a name $date and a big integer.
This can be fixed with:
as.POSIXct(dtl$'$date'/1000,origin="1970-01-01")
But it would be nice if fromJSON could note the {"$date":1234} structure and convert it back to POSIX datetime.
@ralmond jsonlite already supports parsing mongo dates into POSIXct.
dt <- Sys.time()
dtl <- fromJSON(toJSON(unbox(dt),POSIXt="mongo"), simplifyVector=TRUE)
I'm not exactly sure why the date parsing is tied to simplifyVector. There is an undocumented simplifyDate parameter to turn off the feature, but setting it to TRUE doesn't work unless simplifyVector is also enabled.
The simplifyVector=FALSE is important for my use case. I'm trying to store S4 objects as documents in a mongo database collection. I find it easier to work with the raw lists rather than a data frame with one row. You can see my code at my mongo project.