You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe what you want to achieve. I have two json files that I want to read into json objects. Once the files are read in, I want to compare the two objects, and produce a third object (which will be written out to a file) containing the differences.
Describe what you tried. I tried the following (abbreviated) code:
It fails on that input, and the program aborts. The Visual Studio decoder says:
Unhandled exception at 0x75581932 in compareScrape.exe: Microsoft C++ exception: nlohmann::detail::parse_error at memory location 0x011FE1C0. occurred
It opens json.hpp to line 4459, which is the JSON_THROW line below:
case 4:
JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
// LCOV_EXCL_START
I also tried "json baseJObject = json::parse(inFileJSON);", but got the same results. I reduced my tests down to very, very small files (see post over on Stack Overflow: https://stackoverflow.com/questions/58566296/opening-a-json-file-giving-fits), but it still fails (please note that the while loop shown there was added for debug purposes. It is not in the actual failing function. I was just checking to see if I could read the file). I've tried to ensure that everything is UTF-8 using Notepad++ and Get-Content in PowerShell (no luck). Cygwin Bash reports the files as UTF-8... If that is the problem, I guess I need to figure out how to programatically ensure that my input files are all UTF-8.
Describe which system (OS, compiler) you are using. Visual Studio 2017 Windows 10 Pro
Describe which version of the library you are using (release version, develop branch). 3.7.0
This has been very frustrating as the failure seems arbitrary. I've used the same basic syntax in other programs, and it has worked. On the other hand, on a program last week I had this problem and somehow recreating the Visual Studio project and recompiling somehow fixed it (or I got lucky with my input files)
Any suggestions would be greatly appreciated. I guess we could rewrite this in Python, but we were hoping a C++ executable would be more efficient...
Would something like this UTF-8 library solve this issue?
I saw another comment that my code was causing the parser to see EOF and that is what caused the error; so how can I avoid that?
Thanks--
Al
The text was updated successfully, but these errors were encountered:
My apologies for taking so long to reply. It seems to be working now. I
think it may have been some kind of error in the JSON file. We seem to
have this resolved now. Thank you for your help.
Best--
Al
On Sun, Nov 10, 2019 at 3:09 PM Niels Lohmann ***@***.***> wrote:
Do you need further assistance with this issue?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1814?email_source=notifications&email_token=ALF36EODXGYF7MYCSAGBO6LQTB2CLA5CNFSM4JFLESZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDVG24Y#issuecomment-552234355>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALF36EO66BWLJL4JGVUHIQDQTB2CLANCNFSM4JFLESZA>
.
Describe what you want to achieve. I have two json files that I want to read into json objects. Once the files are read in, I want to compare the two objects, and produce a third object (which will be written out to a file) containing the differences.
Describe what you tried. I tried the following (abbreviated) code:
It fails on that input, and the program aborts. The Visual Studio decoder says:
Unhandled exception at 0x75581932 in compareScrape.exe: Microsoft C++ exception: nlohmann::detail::parse_error at memory location 0x011FE1C0. occurred
It opens json.hpp to line 4459, which is the JSON_THROW line below:
I also tried "json baseJObject = json::parse(inFileJSON);", but got the same results. I reduced my tests down to very, very small files (see post over on Stack Overflow: https://stackoverflow.com/questions/58566296/opening-a-json-file-giving-fits), but it still fails (please note that the while loop shown there was added for debug purposes. It is not in the actual failing function. I was just checking to see if I could read the file). I've tried to ensure that everything is UTF-8 using Notepad++ and Get-Content in PowerShell (no luck). Cygwin Bash reports the files as UTF-8... If that is the problem, I guess I need to figure out how to programatically ensure that my input files are all UTF-8.
Describe which system (OS, compiler) you are using. Visual Studio 2017 Windows 10 Pro
Describe which version of the library you are using (release version, develop branch). 3.7.0
This has been very frustrating as the failure seems arbitrary. I've used the same basic syntax in other programs, and it has worked. On the other hand, on a program last week I had this problem and somehow recreating the Visual Studio project and recompiling somehow fixed it (or I got lucky with my input files)
Any suggestions would be greatly appreciated. I guess we could rewrite this in Python, but we were hoping a C++ executable would be more efficient...
Would something like this UTF-8 library solve this issue?
I saw another comment that my code was causing the parser to see EOF and that is what caused the error; so how can I avoid that?
Thanks--
Al
The text was updated successfully, but these errors were encountered: