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

uint64_t being converted to int64_t in to_json #4535

Closed
2 tasks
adlai-shawareb opened this issue Dec 11, 2024 · 2 comments
Closed
2 tasks

uint64_t being converted to int64_t in to_json #4535

adlai-shawareb opened this issue Dec 11, 2024 · 2 comments
Labels
aspect: binary formats BSON, CBOR, MessagePack, UBJSON kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@adlai-shawareb
Copy link

Description

I am getting this runtime error:

Error converting JSON to BSON ([json.exception.out_of_range.407] integer number 18446744073701195776 cannot be represented by BSON as it does not fit int64

If I comment out use of the uint64_t value in to_json, and from_json, I don't get the error.

This appears to be very similar to Issue #4236, but not sure if it is the same.

If it is the same issue, do we know when 3.11.4 will be released?

Reproduction steps

This code will reproduce it:

uint64_t m_Data0 = 0;

inline void to_json( nlohmann::json& j, const Info& cInfo )
{
    j = nlohmann::json{ 
           { "Data0", cInfo.m_Data0 } };

Expected vs. actual results

I expect to_json to bring the uint64_t into the json object as a uint64_t.

Minimal code example

No response

Error messages

No response

Compiler and operating system

Ubuntu 22.04 LTS

Library version

3.10.5

Validation

@nlohmann
Copy link
Owner

Looks like #3894

@nlohmann
Copy link
Owner

Fixed by merging #4590.

@nlohmann nlohmann added aspect: binary formats BSON, CBOR, MessagePack, UBJSON solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Jan 10, 2025
@nlohmann nlohmann added this to the Release 3.11.4 milestone Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspect: binary formats BSON, CBOR, MessagePack, UBJSON kind: bug solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants