-
-
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
crash on empty ifstream #521
Labels
Comments
Which version are you using? |
the latest, (of what?) |
I meant the version of the library. In the #include <json.hpp>
#include <fstream>
using json = nlohmann::json;
int main()
{
std::ifstream f_empty("empty.json");
json j = json::parse(f_empty);
std::cout << j << std::endl;
} aborts with
Apart from the file position (2) this seems to make sense. What did you expect? |
you are right, I was confusing it with an empty json “”.
From: Niels Lohmann
Sent: Saturday, March 18, 2017 12:43 PM
To: nlohmann/json
Cc: Christoph ; Author
Subject: Re: [nlohmann/json] crash on empty ifstream (#521)
I meant the version of the library. In the develop branch, the following program
#include <json.hpp>
#include <fstream>
using json = nlohmann::json;
int main()
{
std::ifstream f_empty("empty.json");
json j = json::parse(f_empty);
std::cout << j << std::endl;
}aborts with
libc++abi.dylib: terminating with uncaught exception of type nlohmann::detail::parse_error:
[json.exception.parse_error.101] parse error at 2: parse error - unexpected end of input
Apart from the file position (2) this seems to make sense. What did you expect?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if file is empty, parsing crashes.
The text was updated successfully, but these errors were encountered: