Comments (3)
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 fromNSStuff
to keep as close to “pure Swift” as possible. (I don’t know much about this, but I got the impression thatNSStuff
tends to be more fragile on other platforms. But maybe that’s just irrational fear?) If there are no problems withDouble
that we know of, let’s keep the number asDouble
internally? - The proposed
NSNumber
number vs. bool solution seems fine. I don’t mind breaking backwards compatibility by replacingfloatValue
bydoubleValue
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.
Very happy to contribute 😁
-
PR 30 improves the handling of large numbers by using
Double
instead ofFloat
. 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 withDouble
andNSNumber
is only used internally as part ofinit(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.
Merged 🎉, thank you again for the contribution.
from generic-json-swift.
Related Issues (16)
- Publish new version of the pod? HOT 2
- Add support for Swift Package Manager
- Automate release process HOT 1
- Add Linux support
- Switch to a cross-platform framework
- Usage after decoding HOT 6
- Initialisation using `nil` or `NSNull` HOT 5
- Tags Are Not SPM-Compliant HOT 3
- JSON initialisation using variables of primitive type HOT 2
- Mutation support HOT 2
- How to use JSON in Core Data HOT 7
- Provide `Decoder` to turn `JSON` into `Decodable` HOT 2
- Loop through JSON keys?
- Improve querying using dynamic member lookup? HOT 1
- Merging JSON values 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 generic-json-swift.