4 ms·
json is fine until your config system needs accurate numeric values.
by harrytuttle 13y ago
json is fine until your config system needs accurate numeric values.
- shuzchen 13y agoNothing in the json spec requires that numbers are limited to those internally representable in a javascript runtime. With the right tooling, you can encode/decode very accurate numeric values. I'm not familiar with the go libraries, but python's simplejson has a use_decimal flag that interprets floats using python's Decimal module. That said, I can't think of any reason a web server needs super accurate numbers. All the config options I can think of require nice round ints. Maybe specifying weights to individual backends to proxy to (so all the weights sum up to 1.0)?
- harrytuttle 13y ago99% of sites are CRUD apps, but we're math heavy financial software. We store a lot of reference data in configuration for performance reasons. This needs to be decimal format. JSON is a subset of the ECMA JavaScript standard which declares only floating point. Do "100!" on wolfram alpha and find me a parser that will load that as an example.
- shuzchen 13y agoworks for me: https://gist.github.com/sirpengi/609711 https://gist.github.com/sirpengi/609711
- harrytuttle 13y agoI get a 404. ?
- shuzchen 13y agoBad copy pasta (missing 3 at the end): https://gist.github.com/sirpengi/6097113 https://gist.github.com/sirpengi/6097113
- stock_toaster 13y agoor until someone wants to put in a comment that documents a change they made at 3am to a production system. I think I would prefer toml take off as a config language.
- harrytuttle 13y agoGood point. We use XML (still after 10 years). For all its warts, at least parsers and deserializers work properly.