-
-
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
Can't parse not formatted JSON. #2340
Comments
The error message
states that no input could be read. Can you share the code you use to parse the input? It seems as if the file could not be opened correctly. |
I'm sorry, my bad. I download the needed JSON and the problem is somehow connected with that. Everything works when I try to parse already existing file (which I've downloaded a while ago). |
If somebody interested - I should've close the file into which I was downloading JSON data. And only after closing I parse with nlohmann. |
@biggerevil |
Update: The problem was I didn't close file after downloading JSON. You need to close file at first and only then parse with nlohmann.
I'm trying to parse JSON in C++ with nlohmann/json library. But this library can't parse not formatted JSON.
It gives error:
libc++abi.dylib: terminating with uncaught exception of type nlohmann::detail::parse_error: [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal
This JSON gives error:
But nlohmann works fine with JSON like this:
Is there a way to format JSON from first format to the second one in C++ code? Without using websites. Maybe there's a library for this, or it's achievable with just C++ or STL.
Update: The problem was I didn't close file after downloading JSON. You need to close file at first and only then parse with nlohmann. The same what I wrote in the beginning of this comment. Just in case somebody misses it.
The text was updated successfully, but these errors were encountered: