Giter Club home page Giter Club logo

Comments (3)

zoul avatar zoul commented on June 17, 2024

Thank you, great suggestions! My thoughts:

  • The JSON spec doesn’t mandate any numeric representation. The conservative approach would be treating the numbers transparently, ie. using some big num machinery instead of (always problematic) floating point. The performance would probably go down, but I don’t think people care in this context. Main problem is that there is no standard bignum support in Swift (or is there?) and I’m not much keen on including an extra dependency.
  • As for Double vs. NSNumber, I’d like to stay away from NSStuff to keep as close to “pure Swift” as possible. (I don’t know much about this, but I got the impression that NSStuff tends to be more fragile on other platforms. But maybe that’s just irrational fear?) If there are no problems with Double that we know of, let’s keep the number as Double internally?
  • The proposed NSNumber number vs. bool solution seems fine. I don’t mind breaking backwards compatibility by replacing floatValue by doubleValue immediately, seems like users should be able to update their code pretty easily? Or we can add a deprecation warning for one release.

from generic-json-swift.

cjmconie avatar cjmconie commented on June 17, 2024

Very happy to contribute 😁

  • PR 30 improves the handling of large numbers by using Double instead of Float. As to handling even larger floating point numbers, well that is still open for discussion. Maybe we should leave this open ended, and open a new issue if this ever comes up?

  • I think PR 30 solves this. JSON's number case is now associated with Double and NSNumber is only used internally as part of init(Any). This keeps the API Swifty. Regarding the impact on other platforms, I don't have any experience with this so I don't have much to contribute right now.

  • I think a breaking major version bump is fine. I have upgraded my code and it's pretty straightforward.

from generic-json-swift.

zoul avatar zoul commented on June 17, 2024

Merged 🎉, thank you again for the contribution.

from generic-json-swift.

Related Issues (16)

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.