Skip to content
This repository was archived by the owner on Jul 19, 2022. It is now read-only.

Differentiate Integer type from Double type (which was originally named Number) to make it possible to correctly store a 64bit integer on 32bit systems.#41

Open
neevek wants to merge 1 commit intohjiang:masterfrom
neevek:master

Conversation

@neevek
Copy link

@neevek neevek commented Nov 10, 2014

Differentiate Integer type from Double type (which was originally named Number), make it possible to correctly store a 64bit integer on 32bit
systems.

Note: this commit will stop programs that use the original jsonxx lib
from compiling. it is required to change the enum Number to either
Integer or Double accordingly.

Number), make it possible to correctly store a 64bit integer on 32bit
systems.

Note: this commit will stop programs that use the original **jsonxx** lib
from compiling. it is required to change the enum *Number* to either
*Integer* or *Double* accordingly.
@Rapptz
Copy link
Contributor

Rapptz commented Nov 10, 2014

Since this PR is a breaking change, I recommend adding back the Number enum value back and make it synonymous with Double rather than breaking it completely. I'm not sure if the maintainers would want breaking changes.

@neevek
Copy link
Author

neevek commented Nov 11, 2014

@Rapptz, I think adding back the Number enum may confuse users after the change, Number=Double is weird to me. Anyway, the maintainers make their decision.

@r-lyeh-archived
Copy link
Contributor

what about adding the compatibility enum with a comment like following?

// Number is deprecated and discouraged to use. Will be removed eventually.
// Use Double or Integer instead.
Number=Double, 

@neevek
Copy link
Author

neevek commented Nov 17, 2014

It's okay to me :)
But there's still one thing to note, this commit also to some extent makes the library harder to use because now we always have to explicitly specify either Integer or Double, instead of just Number.

@bouviervj
Copy link

Hi,

I would prefer an implementation that respects the RFC:
http://www.ietf.org/rfc/rfc4627.txt

"The representation of numbers is similar to that used in most
programming languages. A number contains an integer component that
may be prefixed with an optional minus sign, which may be followed by
a fraction part and/or an exponent part."

Why not just address all these problematic programmatically instead ? I think in Number, we address something that can be a float or a pure integer. Internally we can build a more complex structure that switches between long or double.
But the vocabulary used in JSON is a Number.

Just my point of view :-)
Cheers.
Julien

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants