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

Incorrect parsing of large int64_t numbers #287

Closed
mariobadr opened this issue Aug 2, 2016 · 2 comments
Closed

Incorrect parsing of large int64_t numbers #287

mariobadr opened this issue Aug 2, 2016 · 2 comments
Labels
solution: invalid the issue is not related to the library

Comments

@mariobadr
Copy link

mariobadr commented Aug 2, 2016

Hello,

I use dynamic instrumentation to gather information about a program, and then output it using your json library to a file. When I parse the file into a different application using your library, I get different values. Below is a minimal example:

main.cpp

#include <fstream>
#include <iostream>

#include "json.hpp"

int main(int argc, char** argv) {
  using json = nlohmann::json;

  if(argc != 2) {
    return 0;
  }

  std::ifstream stream(argv[1]);
  json j;
  stream >> j;

  std::cout << j["id"] << "\n";

  return 0;
}

test.json
{ "call": "pthread_mutex_lock", "id": 8492065431569638403, "object": 139898772169632 }

Output
8492065431569638400

The documentation states that numbers are stored in int64_t, and that the maximum value allowed is 9223372036854775807. The above value is less than that number, so I'm not sure what the problem is. Thanks.

Edit: I am using version 1.1.0

@mariobadr
Copy link
Author

mariobadr commented Aug 2, 2016

Sorry, just noticed #178/#183 and tried out version 2.0.2 and everything works fine now. Thanks for the awesome library!

@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Aug 2, 2016
@nlohmann
Copy link
Owner

nlohmann commented Aug 2, 2016

No worries! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants