19 chars · 3 lines
Two-way sync · Edit either side and the other updates automatically.
"attempt": 0119 chars · 3 lines
Two-way sync · Edit either side and the other updates automatically.
"attempt": 01JSON number syntax error
JSON numeric grammar treats zero as a complete integer unless a decimal or exponent follows. Writing 01 therefore looks like one number ending at 0 followed immediately by another numeric token. This tool is free to use. No account or payment is required.
Last updated
A count of 01 and a count of 1 represent the same numeric value, so the valid JSON number is 1. A code such as 00123 may need to remain five characters long and therefore belongs in a string.
If leading zeros carry business meaning, model the field as text. Removing the zeros simply to satisfy the parser can change identifiers even though it preserves numeric value.
The numeric attempt count should be written as 1 rather than 01.
{
"attempt": 01
}{
"attempt": 1
}Common questions
No. Standard JSON does not allow an integer to contain an unnecessary leading zero.
If the leading zeros are meaningful, store the value as a string such as "00123" rather than as a number.
No. JSON has a single decimal number grammar and does not support JavaScript-style octal literals.
Debugging a specific JSON issue? Browse JSON troubleshooting.