-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
boolean encoding is inconsistent #161
Comments
so I guess this means it's not actually fixable. I hope I'm wrong though. |
SV_yes and SV_no should not be interpreted as JSON booleans (unless via Cpanel::JSON::XS::Type with the boolean type). The user cannot easily tell if something they have is one of these special constants, they might accidentally encode one of them when trying to encode the number 1 (for example), and as demonstrated here they can de-special themselves. They are simply not reliably distinct from 0 and 1 in implementation or interface. |
I don't agree with this part, as that's the same problem we have with the difference between the string |
It is similar, and it's not good that that happens either. But in this case, we can avoid the problem and everything still works intuitively. |
Not really, !0 is always SV_YES, even if as arrayref.
It's the anonlist in perl before the XS encode which changes the [yes] to [1].
So it's BTW: Trivially fixable there, but it's already too late. |
My concern is even if that were reliable, it's very common to already be using these values and expecting a 1 on encode, because it's generally indistinguishable from 1 in perl code. The boolean object is the only consistent and obvious way to represent something to be encoded to a boolean without Cpanel::JSON::XS::Type, and people are already used to it. |
This is with version 4.19.
The text was updated successfully, but these errors were encountered: