JSON values 1 or 0 - int or boolean
The values true
and false
are actual boolean values, the rest are integers. See http://json.org/ for more.
JSON is a format for transferring data.
It has no notion of equality.
JSON parsers treat booleans and numbers as distinct types.
I prefer using 0/1 instead of true/false, because 0/1 consume only 1 byte while true/false consume 4/5 bytes.
As mentioned, at JSON level, 0 and false are not the same; data types are number versus boolean. But JSON processing libraries can choose to do conversions; especially on languages/platforms that do not have native boolean type, for example. In that case, another representation may be used (empty string or 0 for false).
Further, it is also possible that processing libraries can coerce types: such that if a boolean value is expected, certain number/string values (or JSON 'null' token) can be accepted instead. This is fairly common, due to differences on data type choices on different languages.