Giter Site home page Giter Site logo

stringification of true about cpanel-json-xs HOT 6 CLOSED

rurban avatar rurban commented on June 29, 2024
stringification of true

from cpanel-json-xs.

Comments (6)

kanatohodets avatar kanatohodets commented on June 29, 2024 1

I just bumped into this today for the same reason: I had a Moose Bool type constraint, which checks for "1" and "0" (https://github.com/moose/Moose/blob/master/lib/Moose/Util/TypeConstraints/Builtins.pm#L44). My API client library did use JSON and all my tests were good. When I started using the library in an environment where Cpanel::JSON::XS was imported, my type constraints started to fail due to the override of JSON::PP::Boolean.

I handled this for the moment with coercion for the Moose attributes, but it was a bit of a surprise to discover this difference.

If you don't have strong opinions on this front, I would propose consistency with other notions of string boolean in JSON libraries, Moose, and boolean.pm: use "1" and "0" as the string representations of Cpanel::JSON::XS::true/Cpanel::JSON::XS::false.

from cpanel-json-xs.

rurban avatar rurban commented on June 29, 2024 1

ok, let's do "1" then

from cpanel-json-xs.

rurban avatar rurban commented on June 29, 2024

I thought it's a superior representation than 1 and it's still true. JSON::XS had a bug in it's overload approach, which I fixed, so I could finally do it.
But I'm open minded about it, and never heard about Moose's Bool constraint.

from cpanel-json-xs.

sezal avatar sezal commented on June 29, 2024

@kanatohodets, I strongly agree with you. It's very frustrating for those who are trying to jump from JSON::XS. I'd vote for "1", but potentially it can break someones code.

from cpanel-json-xs.

karenetheridge avatar karenetheridge commented on June 29, 2024

closed in #87

from cpanel-json-xs.

rurban avatar rurban commented on June 29, 2024

Fixed in Release 3.0236

from cpanel-json-xs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.