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

Big uint64_t values are serialized wrong #1327

Closed
ctxhaard opened this issue Oct 30, 2018 · 0 comments
Closed

Big uint64_t values are serialized wrong #1327

ctxhaard opened this issue Oct 30, 2018 · 0 comments

Comments

@ctxhaard
Copy link

ctxhaard commented Oct 30, 2018

I have to put unix timestamp into a json document; it is a unix timestamp in milliseconds (instead of seconds since 1970):

nlohmann::json j;
uint64_t dd = ((uint64_t)time(nullptr) * 1000);
nlohmann::json jdd( dd );
j ["dd"] = jdd;

std::stringstream stream;
stream << std::setw(4) << j;

std::string finalvalue = stream.str();

on my 64bit workstation I get the value serialized the right way:

{
    "dd": 1540897022000
}

on a arm 32bit device I get the value serialized wrong:

{
    "dd": 18446744072713095352,
}

@ctxhaard ctxhaard changed the title Big uint64_t values are serialized as negative on 32 bit machine Big uint64_t values are serialized wrong Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant