-
-
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
stream error #815
Comments
Could you please try with the |
How would I go about doing that? Also, I ran the same program from my linux command line and the program executed perfectly. The issue I've reported happens when using CLion. |
Please try with this header: https://github.com/nlohmann/json/raw/develop/src/json.hpp |
Any news on this? |
Sorry, I was out deer hunting this past weekend and I've had some other projects to work on. I will try it tonight. |
I still receive an error, here's the output
|
It seems the file could not be opened - the first thing the parser sees is the end of file. In your example, can you make sure it is properly opened? Can you |
So I did manage to figure it out, I simply added the whole file path instead of just the file name. Thanks for all your help, this newbie appreciates it! |
No worries. Thanks for checking back! |
Hello, I have the same issue, its working only for the whole file path but its not a solution for me. :-( |
This isn't an issue related to this repository, it's an issue connected to your IDE |
@feugen Could you please provide more information? |
What information do you need? I am using QtCreator and I dont thinnk its an IDE issue. The output of the binary is wrong, it says
If I use the full path to my json file, I dont get this error, the output of the binary is the expected one. |
That's because if you don't use the full path to the file, then the part you use is combined with the working directory to form the full path. If you just include the filename and not the path, then it will only find your file if your working directory is the directory containing the file. That depends on how you're running the program. It is not related at all to this library. You'll find that this error does not change even if you remove all traces of the JSON library from your program. |
Ah ok, just moved my json file to a working directory and the error is gone, lol. Thanks |
Hi, I'm still getting the same error as @ghost, where my error is: terminate called after throwing an instance of 'nlohmann::detail::parse_error' what(): [json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal How would I approach it? I tried using the whole path, but that doesn't seem to be fixing it. -- Adit |
Can you access the content of the file without passing it to the JSON library? |
So apparently my issue has something to do with initializer lists, dsteeam and command line args. When I pass a command line argument [: jsonFileIn(argv[2])] through an fstream initializer list, it didn't read anything in the file. But when I explicitly write[ : jsonFileIn("./result.json")] it works. I still don't get why this works, but I guess it does? Long story short, it had nothing to do with your library. |
Thanks for responding so promptly though |
I having a similar problem and I think it is related to the one described in this topic. I am using macOS. If I open a terminal, go to the folder in which the executable is located and run the executable, everything works. But if I run
The |
Looking at |
I have the same problem. I'm getting Json string from TCP protocol. I get some packets perfect but then I get an error " this is how I convert my char into string then into Json " |
The exception says the received JSON is invalid. Try to print |
@nlohmann You are right the string which I was receiving was incomplete. Your library works perfect! Thank you. |
@nlohmann Hello When I used this code |
The error means in 99.9% of the time that the stream is broken somehow and the parser could not read a single byte. Please double check that the stream is OK, e.g., by trying to print it to stdout. |
So I want to know how you solved this problem? please |
|
What I meant is that you need to make sure the stream you pass to the library is valid. |
I've been trying to implement this solution and I have been consistently getting the same stream error, regardless of the json file or example I use/follow. I know I'm probably doing something silly but I'm a lowly junior in my CS degree. Here is my code:
and here is the json I've been using:
and here is the error:
/home/bry/CLionProjects/jsonexample/cmake-build-debug/jsonexample terminate called after throwing an instance of 'std::invalid_argument' what(): stream error Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
The text was updated successfully, but these errors were encountered: