Skip to content

uint64_t being converted to int64_t in to_json #4535

@adlai-shawareb

Description

@adlai-shawareb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions