Given the JSON document
{"percentageAmount": .01}
Running it by JSONLint.com results in the error:
Parse error on line 2:
..."percentageAmount": .01}
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
On the other hand, this is valid:
{"percentageAmount": 0.01}
The code is parsed correctly if assigned to a variable as a JavaScript literal, but of course there are many things that are OK for JavaScript variables that aren't JSON spec.
Why is this against JSON spec?
According to the railroad diagram for numbers at JSON.org, numbers with fractional values must have digits before the decimal point:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With