Backport setting time_precision for JSON::Encoding

Backports 2 commits:
* 4cfc467594da86090efa63f1852fb82df9458c2b
* c0965004486f2ea5a9656ba718a3377c9614f97d