{"a" : 01}
or {"a" : -000.1}
is an invalid, but JQ is fine with it and interprets it as {"a" : 1}
and {"a" : -0.1}
.
Is it by design or a bug?
{"a" : 01}
or {"a" : -000.1}
is an invalid, but JQ is fine with it and interprets it as {"a" : 1}
and {"a" : -0.1}
.
Is it by design or a bug?
Since superfluous leading 0s are not allowed in JSON, a "strict mode" might be nice for jq, but without even invoking Postel's Law, it is evidently perfectly reasonable for a tool such as jq to accept them (JSON, after all, is supposed to be human-friendly), so long as the output that is supposed to be JSON is valid.
And besides, there are plenty of dour linters.
By the way, FWIW, NaN and Infinite are also accepted as input (and interpreted accordingly), so it's evident that jq's creators/maintainers intend there to be a "non-strict" mode when reading JSON texts.
For some background, see Why is JSON invalid if an integer begins with a leading zero?
One argument I've seen against allowing superfluous 0s is that since 00
is not valid JSON, a tool that purports to read streams of JSON should recognize 00
as two 0s. This is indeed the way that gojq's JSON parser handles leading 0s.