reapply Duncan’s fix https://github.com/jeroenooms/jsonlite/commit/1bdba31f9e78b6ff6c5825cc07845407ae9a0c8f