mozilla/rust — pull request #13869 by zr40 (2014-04-30 22:55:43+00:00)
Title: Allow parsing of JSON numbers using number types other than f64

This change allows numbers in JSON data to be parsed using any number type. With `f64`, integer values would lose precision once they exceed 2^53.

This is accomplished by changing `Number(f64)` to `Number(~str)`, storing the input string instead of the parsed f64. The conversion now takes place in `.as_number()` using the type parameter with `FromStr`.

Notable changes to tests:
* Added a case to check reading and writing a big integer without loss of precision.
* In `test_decode_numbers`, I've changed `0.4e-01` to `0.5e-01` to avoid one-bit difference between compiled constant and `from_str` output for the former number.