-
-
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
parse error - unexpected <uninitialized> with 2.0.5 #325
Comments
I cannot reproduce the error. I'm using the current code from the develop branch as well as the 2.0.5 release: #include <fstream>
#include <json.hpp>
using json = nlohmann::json;
int main()
{
std::ifstream f("issue325.json");
json j = json::parse(f);
std::cout << j << std::endl;
} The output is {"accounts":{"invalid_email_domains":["mailinator.com"],"invalid_usernames":["admin","moderator","administrator","mod","sys","system","community","info","you","name","me","username","user","nickname","thinger","root"],"min_password_length":6,"require_email_verification":true,"required_email_domains":[]},"buckets":{"export":{"filesystem":{"export_path":"/Users/alvarolb/Desktop/buckets_exports"},"type":"filesystem"},"storage":{"mongodb":{"database":"thinger_data","host":"localhost","password":"","table":"buckets_data"},"type":"mongodb"}},"database":{"mongodb":{"host":"localhost","password":""},"type":"mongodb"},"http_server":{"address":"0.0.0.0","hosts":[{"host":"*","type":"rest"}],"port":"8080"},"log":{"enabled":true,"level":"debug","output":{"clog":{"enabled":true},"file":{"enabled":false,"flush":false}}},"thing_server":{"address":"0.0.0.0","port":"25200"}} |
Not sure if it may be related with the compiler version, but I am using clang 3.8.1 on Mac. |
I now also tried your code: #include <fstream>
#include <json.hpp>
using json = nlohmann::json;
int main()
{
std::ifstream file("config.json");
std::string json_config_str((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
file.close();
nlohmann::json config = nlohmann::json::parse(json_config_str);
std::cout << config << std::endl;
} It also worked without problems. To rule out compilers: I am using macOS Sierra with Apple LLVM version 8.0.0 (clang-800.0.38). I shall add a test case and let it run through the compilers at Travis and AppVeyor - maybe the bug is triggered there. To help debugging, you may try on of the following:
|
Sorry for your time @nlohmann I have isolated the project to the basic example, and it just worked fine. Then I realized that I was mixing two different versions of the library in the project (in different folders). One with the 2.02 and, other with 2.05. When using 2.02 it worked since both versions were the same, however, while using 2.05 along with 2.02, it compiled but crashed at runtime. Thanks for your support and your awesome library. |
No worries. |
Hi,
I have been using this library for a long time now. Today, after updating to 2.05, my program started to crash while parsing a simple JSON file. Here is the sample json:
The code is something like:
The error given is:
libc++abi.dylib: terminating with uncaught exception of type std::invalid_argument: parse error - unexpected <uninitialized>
I have tested the same code with 2.04, and 2.03, and I am still getting the same error. Meanwhile, I have switch back to 2.02 that was working fine with this file. I have tested that the JSON is valid also.
Thanks for your support and your awesome work!
The text was updated successfully, but these errors were encountered: