jsonlite
jsonlite copied to clipboard
Respect scipen option or add an explicit scipen option to `toJSON`
There are use cases when the difference between 0.0001 and 1e-5 is crucial.
My use case is to print two jsons and run diff tools on the output to detect any regularities between expected and produced jsons in tests.
The problem is that on some inputs scipen is not applied and I am getting spurious failures like:
- "pred.applied": 1e-05,
+ "pred.applied": 0.00001,
Also it seems like digit argument is not quite respected:
> (toJSON(0.0001, pretty = TRUE, digits = 3))
[0]
> (toJSON(0.00001, pretty = TRUE, digits = 3))
[1e-05]
>