mono/mono — pull request #1148 by steffen-kiess (2014-07-07 17:36:49+00:00)
Title: Fix several issues in System.Json

This commit fixes several issues in System.Json

- Fix detection of extra characters in JSON input (e.g. reject "1 1")
- Fix detection of invalid negative numeric literals (e.g. reject "- ")
- Disallow leading zeros. Leading zeros are a bad idea because JavaScript will parse them as octal values.
- Use "round-trip" format for floating point numbers. This should ensure that writing a double to a json file and reading it back will yield exactly the same value.
- Serialize NaN and Infinity as strings. Currently NaN gets serialized as "NaN" (with quotes) but Infinity as Infinity or -Infinity (without quotes). The forms without quotes are not valid JSON. This commit also makes sure that the forms with quotes can be converted back to double.
- Use NumberFormatInfo.InvariantInfo for Convert.To*(). These conversions shouldn't depend on the locale. (I.e. (double)JsonValue.Parse("\"0.5\"") should always work and return 0.5)
- Use standard number parsing methods in ReadNumericLiteral(). This fixes lots of problems with parsing large / small exponents. Parsing values as decimals and then converting it to double will causes rounding problems in many cases.
- Add test cases. I've added test cases for basically all the stuff that was changed / fixed.