dropbox / json11

A tiny JSON library for C++11.
MIT License
2.54k stars 613 forks source link

add decimal support #112

Closed microcai closed 6 years ago

microcai commented 6 years ago

this pull request add decimal floating point support.

without decimal support, 0.1 is not 0.1 as it looks. people from non-C world tend to use decimal directly in their json exchange data, if we don't support decimal, then we lose precision.

j4cbo commented 6 years ago

Hm, this probably makes more sense as a fork than part of mainline json11. Adding a dependency on boost isn't an option for many users.

artwyman commented 6 years ago

I agree with @j4cbo. I think there's an interesting discussion to be had about possible features to preserve accuracy of decimals (beyond what a double provides), and the trade-offs of complexity vs. correctness. However, doing so by adding a boost dependency, and apparently turning on exceptions and RTTI if the CMake file is to be believed, would put a burden on many potential users of the library (including Dropbox, which doesn't currently link Boost in our mobile apps), so I think it would be better served as a fork. Simplicity in implementation and dependencies is one of the goals of this library (as per the opening sentence of the readme: "json11 is a tiny JSON library for C++11").

The license does allow for forks and modifications, though, so have at it. I'm glad you're finding json11 useful, and thanks for contributing.