Replies: 1 comment 3 replies
-
If that's your exact code, then your compiler must be doing something wrong. That works fine on Clang and GCC. https://compiler-explorer.com/z/vzahxrnc7 |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there all,
Some introductory information: I am new here and to this json library, so this might be a simple fix, but I couldn't find information about it. I am using the library with IAR EW 9.30.1.
I am having issues with serializing an array of floating-point numbers, both float and double. This library has been working well for me and my purposes so far. I just hit this issue today and was wondering if anyone might know what is going wrong.
So, I shrunk the example down for the sake of compactness, but this happens with any size array.
`
json jsonObject;
std::vector doubleArray = {10.0, 15.0, 20.0};
std::vector<uint32_t> intArray = {0, 1, 2};
jsonObject["doubles"] = doubleArray;
jsonObject["ints"] = intArray;
std::string testString = jsonObject.dump();
`
I can set breakpoints and see that the vectors, and jsonObject have the proper values in them. But after using dump(), the resulting string looks like this:
{"doubles":[%g.0,%g.0,%g.0], "ints":[0,1,2]}
So, the integers work perfectly, but I get these strange values for when the doubles are serialized. Every single double/float no matter the value gets set to %g.0 and I have no idea why. If anyone has a clue, I would appreciate it.
Beta Was this translation helpful? Give feedback.
All reactions