-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Unhandled exception: nlohmann::detail::parse_error #3078
Comments
I can't find an instance of (Removing the bug label as this is very likely just an error in the application to properly open a file). |
This means that your program is failing to open the file. |
Why would that be happening? I see no bugs in my code where the file wouldn't open... Do any of you use Visual Studio Comminuty on Windows? If so it may be easier to find the bug by compiling, debuging and editing the code with it like I am. |
There are plenty of exceptions in your screenshot, but the first one indeed points out that either the file you want to parse is empty or could not be opened. Best would be to run your program in the debugger to see stack traces in case of an uncaught exception. |
Most likely the file is not where you think it is relative to the working directory. Try using a full path instead of a relative path. Another possibility is that you are using Unix path separators on Windows. Try using You can verify that you are opening the proper file by reading from it and then printing to the console. Note that you can't then use the same stream in the |
std::ifstream FileRead("test\\test.json"); This is a relative path to file |
It wasn't there, but even when I added it I still got a problem, I am also asking on Microsoft's Q&A center about the problem with Visual Studio Community. I'll let you know if I find anything or if the problem is solved. |
In the code below, replace
|
Now I have the actual path of the file, and now I know the problem is with the file path!? I still can't find the relative path, but at least I have the actual path and it works. Any tips about were the relative path is? Edit: Is there some way to output the current directory in C++? Maybe then I can find where I should put the json file as a relative path. |
Alright, I found out my problem, at first I thought there was a problem with the I hope I make sense, and thank you for your help! |
What is the issue you have?
I have an Unhandled exception error:
Exception thrown at 0x76BBB5B2 in guessTheNumber.exe: Microsoft C++ exception: nlohmann::detail::parse_error at memory location 0x012FE18C.
Unhandled exception at 0x76BBB5B2 in guessTheNumber.exe: Microsoft C++ exception: nlohmann::detail::parse_error at memory location 0x012FE18C.
And Visual Studio 2022 says the error is on line 6176
Please describe the steps to reproduce the issue.
Can you provide a small but working code example?
My code is hosted on github here
What is the expected behavior?
Uhh, for the code to run and not give an error? I don't really understand the json.hpp code yet
And what is the actual behavior instead?
Two errors:
Exception thrown at 0x76BBB5B2 in guessTheNumber.exe: Microsoft C++ exception: nlohmann::detail::parse_error at memory location 0x012FE18C.
Unhandled exception at 0x76BBB5B2 in guessTheNumber.exe: Microsoft C++ exception: nlohmann::detail::parse_error at memory location 0x012FE18C.
Which compiler and operating system are you using?
Which version of the library did you use?
develop
branchIf you experience a compilation error: can you compile and run the unit tests?
I don't know how to turn that on in Visual Studio 2022, I don't use cmake to compile my code.
The text was updated successfully, but these errors were encountered: