Giter VIP home page Giter VIP logo

Comments (3)

artwyman avatar artwyman commented on July 20, 2024

@j4cbo might remember best the logic behind deciding not to do that (or the similar operator bool approach) when this library was first developed. My thought would be that it would be a pattern easy to misunderstand depending on your expectations of JSON. E.g. it's not obvious if it's checking only for null, or also for a boolean value (it's a bit awkward to have a boolean operation which has a different meaning from bool_value()), or integer values which C++ programmers would expect to be true if non-zero, or other values which would be defined as "falsy" by JavaScript or Python, like empty strings, empty arrays, etc. Making any test explicit rules out any confusion about what exactly it should mean.

from json11.

j4cbo avatar j4cbo commented on July 20, 2024

Yep, that's exactly it. There are a bunch of possible meanings of an implicit boolean cast. Making the cast check only for null would be one option, but Javascript also has its own convoluted truthiness semantics which are kinda convoluted, and which users might expect. Any possible meaning of an implicit cast might be surprising to someone, so we decided to require that the intent be written out explicitly.

from json11.

ttti07 avatar ttti07 commented on July 20, 2024

Oh, I didn't think of that about... Your decision seems reasonable, and I agree with that philosophy too.
Keep the most appropriate way of C++. Thanks for your explanation.

from json11.

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.