Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON parser does not handle 64-bit numbers correctly #32

Closed
naquin opened this issue Dec 13, 2012 · 0 comments
Closed

JSON parser does not handle 64-bit numbers correctly #32

naquin opened this issue Dec 13, 2012 · 0 comments
Labels

Comments

@naquin
Copy link

naquin commented Dec 13, 2012

When you give a number that is greater than 2^32, the JSON parser converts it to a 32-bit integer. The following code illustrates:

std::string json = "{ \"test\" : 5000000000000000 }";
Parser parser;
Var result;

try
{
    DefaultHandler handler;
    parser.setHandler(&handler);
    parser.parse(json);
    result = handler.result();
}
catch(JSONException& jsone)
{
    std::cout << jsone.message() << std::endl;
    assert(false);
}

assert(result.type() == typeid(Object::Ptr));

Object::Ptr object = result.extract<Object::Ptr>();
Var test = object->get("test");
assert(test.isInteger());
Int64 value = test;
assert(value == 5000000000000000); // fails here, value gets truncated
aleks-f added a commit that referenced this issue Dec 14, 2012
Fix JSON Parser to handle 64-bit integers (Issue #32)
@naquin naquin closed this as completed Dec 14, 2012
obiltschnig pushed a commit that referenced this issue Jan 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant