Skip to content
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

Exception Unhandled out_of_range error #2197

Closed
duojet2ez opened this issue Jun 17, 2020 · 6 comments
Closed

Exception Unhandled out_of_range error #2197

duojet2ez opened this issue Jun 17, 2020 · 6 comments
Labels
kind: question platform: visual studio related to MSVC state: needs more info the author of the issue needs to provide more details

Comments

@duojet2ez
Copy link

Hello,

Thanks for this library and for answering questions!!

The library was working perfectly when I was working without an IDE. I just brought my files into visual studio and am getting the following error when trying to cout from my .json file:

Unhandled exception at 0x75754402 in Epic Disaster Story.exe: Microsoft C++ exception: nlohmann::detail::out_of_range at memory location 0x009CE6C0. occurred

It takes me to json_sax.hpp and shows the following code where the error occurred:


JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));

In my code this occurs when I try:

std::cout << j["pages"][0]["text"]; 

I believe the json file is formatted properly as I had no problems without the IDE...

@nlohmann
Copy link
Owner

I would need more information to diagnose this. What is the what() string of the exception? Can you provide a code example?

@nlohmann nlohmann added state: needs more info the author of the issue needs to provide more details platform: visual studio related to MSVC labels Jun 17, 2020
@Journeyman1337
Copy link

Same exception in Visual Studio 2019. The error occurred for me when trying to stream into the json directly from an std::fstream. To view the What() string you asked for, I had to use debugging tools.

[json.exception.parse_error.101] parse error at line 115, column 9: syntax error while parsing object - unexpected string literal; expected '}'

Just like duojet2ezz, the json file I am using has no syntax errors, as I have checked it with multiple validators.

raw text:
https://pastebin.com/iEzCy6fW

@duojet2ez
Copy link
Author

duojet2ez commented Jun 27, 2020

Looks like it doesn't like copying and pasting text in the string in the json file... So when I type in my text it works.. but copying it from another document does not.

It's going to be very time consuming to retype reams of text v just copying it to my json file. Is this a known issue and what additional information can I provide you with if it is not? Thanks for all the help!!

@nlohmann
Copy link
Owner

Thad is odd. No, this is not a known issue. The library perfectly supports UTF-8 - maybe your editor adds some weird bytes or encoding when copy/pasting? Maybe you can attach a working and non-working file so we can look at the binary diff?

@duojet2ez
Copy link
Author

duojet2ez commented Jun 27, 2020

Which files from my project would you like? Just the json... one working and one that does not work?

UPDATE: I think I have narrowed down the problem. It seems the behavior occurs when copying and pasting an apostrophe

UPDATE: And also consecutive periods in a row .....

UPDATE: Copying an apostrophe worked in another context... so now I really don't know.

@nlohmann
Copy link
Owner

That sounds like your editor replaces some characters. Which editor do you use?

About the file: Please attach a file that does work if you read it directly, but does not work after copy/pasting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question platform: visual studio related to MSVC state: needs more info the author of the issue needs to provide more details
Projects
None yet
Development

No branches or pull requests

3 participants