A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nst/JSONTestSuite/issues/51 below:

Range and precision for extreme number values · Issue #51 · nst/JSONTestSuite · GitHub

Range and Precision - What about numbers with a huge amount of digits? According to RFC 7159, "A JSON parser MUST accept all texts that conform to the JSON grammar" (section 9). However, according to the same paragraph, "An implementation may set limits on the range and precision of numbers.". So, it is unclear to me whether parsers are allowed to raise errors when they meet extreme values such 1e9999 or 0.0000000000000000000000000000001.

You said it is unclear to me whether parsers are allowed to raise errors but all the extreme values tests are y_* tests. Since the specification is contradictory, I think these tests should be implementation defined instead.

Some parsers, such as jansson and Json.NET has chosen to raise errors:

if((value == HUGE_VAL || value == -HUGE_VAL) && errno == ERANGE) {
    /* Overflow */
    return -1;
}
reader = new JsonTextReader(new StringReader("1E+309"));
ExceptionAssert.Throws<JsonReaderException>(() => reader.Read(), "Input string '1E+309' is not a valid number. Path '', line 1, position 6.");

reader = new JsonTextReader(new StringReader("-1E+5000"));
ExceptionAssert.Throws<JsonReaderException>(() => reader.Read(), "Input string '-1E+5000' is not a valid number. Path '', line 1, position 8.");

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4