-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
lexer::get_number return NAN #82
Comments
Could you please provide more information. From the screenshot, I do not understand where the NAN occurred. Maybe a small example of an input JSON and the code you are using would help. |
Example json on screenshot, is Box.json. get_number fail on ["origin"]["x"] |
I see. However, I cannot reproduce this - there are several test cases to check get_number. Could you attach the JSON file and give me more information:
|
I call next json j;
file->getStream() >> j; // here getStream() return istream& this in >> operator when json parse file Computer where i repeat error is Compiler: g++ (Ubuntu 4.8.4-1ubuntu15) 4.8.4 |
Could you please also attach the JSON file (or email it to me)? |
I try simple example
and got output
I found out that the reason is not the compiler, not in your library, and not in the json file because another program on this computer with this file it works. But I do not understand why it does not work here. It may be needed to determine what is or to declare further |
maybe some compilation flags needed? |
Thanks for the details. However, I cannot reproduce them - with the latest commit, I added a test case of the code you posted above, and it succeeds on OSX and Linux. |
I also tried the file you sent me with this code: #include <fstream>
#include <json.hpp>
using namespace nlohmann;
using namespace std;
int main() {
json j;
ifstream f("Box.json");
f >> j;
std::cout << j["rigidBodies"][0]["origin"]["x"] << std::endl;
} Compiled with The output is as expected: |
Sorry Niels. Problem was in my library :) |
Niels sorry again. Found an error which indirectly touches your library function in some rare cases, it does not work properly due to the fact that you have a different locale, and she considers the comma separator instead of a period, and then the library does not begin to parse correctly.
It helped me next
I found the solution here http://www.thecodingforums.com/threads/how-to-make-std-strtod-not-depend-on-locale.546559/ I thought maybe you check locale before parsing file |
I see the problem. The linked solution is not really an option, because setting the locale affects the whole program, and not just the JSON class. I see if I can find a different approach. |
The text was updated successfully, but these errors were encountered: