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
support encoding core booleans #62
Conversation
Perl now has support for tracking boolean values. Use this to encode perl booleans as json booleans.
This replaces #55, only including encoding of core boolean values. |
return builtin::is_bool($_[0]); | ||
} | ||
return !!0; | ||
} | ||
|
||
sub true { $JSON::PP::true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It there a reason for not making these two functions return native bools?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #63. It would be unwise to use native bools unless the application is equipped to deal with them everywhere.
Isn't !!0 a native bool (in perl versions where they exist)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!!0
is a native bool, and both is_bool
and isa
should be returning native bools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, if you were referring to the true and false functions, that is because many things expect the bools coming from JSON::PP to be JSON::PP::Boolean objects. For now, I've left those unchanged for backwards compatibility. Also, this PR is only meant to deal with encoding. #63 exists to start dealing with decoding.
Perl now has support for tracking boolean values. Use this to encode
perl booleans as json booleans.