Replies: 1 comment 1 reply
-
The library uses If you want to use #include <iostream>
#include "json.hpp"
int main()
{
std::vector<float> float_data = {0.1234567, 4.123456};
nlohmann::basic_json<std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, float> json;
json["AAA"] = float_data;
std::string ss = json.dump();
std::cout << ss << std::endl;
} Output: {"AAA":[0.1234567,4.123456]} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the issue you have?
I am using nlohmann::json version 0.3.7 in my project, it is a great tool.
But I encounter a small problem: dump a json object which contains float array, seems the precision is incorrect.
Can you provide a small but working code example?
But the output string is:
{"AAA":[0.12345670163631439,4.123456001281738]}
What is the expected behavior?
I suppose the output string should be:
{"AAA":[0.1234567,4.123456]}
Which version of the library did you use?
Beta Was this translation helpful? Give feedback.
All reactions