Comments (9)
Thanks for the good test cases.
Many people do have different opinions about this. But JSON::PP should be matched
from cpanel-json-xs.
so encode should detect builtin::true
, and decode optionally on core_bools
from cpanel-json-xs.
so encode should detect builtin::true, and decode optionally on core_bools
That sounds reasonable to me. I expect that most of the time decoding to a core bool would make sense, but there might be a reason why it should be disabled (e.g. to cope with older code that looks explicitly for JSON::PP::Booleans?) so leaving a way to turn it off would be good.
from cpanel-json-xs.
I agree with @karenetheridge that it would be useful to control the decoding behaviour. Both JSON::PP and JSON::XS allow this via the boolean_values method.
If this gets adopted and the default is off, I'll be looking for a way to turn it on globally, especially when I'm using tools like Mojolicious, where Cpanel::JSON::XS is used internally.
from cpanel-json-xs.
I have prepared support in JSON::MaybeXS to support recognizing core booleans in its is_bool()
interface, but I will wait until Cpanel::JSON::XS supports them before releasing -- otherwise, there might be surprising behaviour due to the mismatch of the results of is_bool()
and serializing those booleans.
from cpanel-json-xs.
Yes, the boolean_values method will also be in, to provide the same API as JSON::PP. I'm just a bit too busy right now
from cpanel-json-xs.
I"ve delayed this feature for the 4.37 fixes for the 5.38 release, because I couldn't get it right yet. XS specialist help appreciated. I took the JSON::PP t/core_bools.t as reference.
from cpanel-json-xs.
XS specialist help appreciated
Any specific questions or advice required?
from cpanel-json-xs.
Any further thoughts here? I'm in the middle of writing some slides to present to FOSDEM, about how Perl has had proper boolean support since 5.36 and "all the serialisation modules will cope", except that I'm finding that most of them still don't. It'd be great to have this sorted and fixed.
I draw specific attention to my question above; namely:
XS specialist help appreciated
Any specific questions or advice required?
from cpanel-json-xs.
Related Issues (20)
- values with IOK and pNOK (but not NOK) encoded as floating point, losing precision HOT 1
- Tests started failing again with recent perls and JSON 4.09 and JSON::PP 4.11
- "Subroutine JSON::PP::Boolean::(++ redefined" with newer perls HOT 2
- Remaining warnings with newer perls and JSON::PP HOT 3
- RFE: utf8(0) variant appropriate for byte strings HOT 26
- Check DOS attack via overlarge bignums
- memory leak when allow_nonref is off HOT 1
- Boolean eq overload breaks behaviour of JSON / JSON::XS modules HOT 1
- Bug: Wrong error messages/sometimes crashes or endless loops with invalid JSON in relaxed mode HOT 2
- Bug: allow_barekey decodes UTF-8 differently with and without quotes HOT 1
- Stringified objects are utf-8 encoded HOT 5
- Build is failing with C error: βforβ loop initial declarations are only allowed in C99 mode HOT 3
- Use faster SIMD utf8 validation
- Strange behvaiour with encode_json. HOT 1
- allow_singlequote should also allow \' HOT 2
- Inconsistent encoding of the empty string HOT 4
- unblessed_bool doesn't DWIM (or match the docs). HOT 3
- test failure with perl-5.38.0-RC0 (t/20_unknown.t) HOT 2
- JS-style comments HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpanel-json-xs.