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

json.exception.parse_error.101 only occurs outside of IDE #3467

Closed
1 of 2 tasks
jasonabuzzell opened this issue May 3, 2022 · 2 comments
Closed
1 of 2 tasks

json.exception.parse_error.101 only occurs outside of IDE #3467

jasonabuzzell opened this issue May 3, 2022 · 2 comments
Labels
solution: invalid the issue is not related to the library

Comments

@jasonabuzzell
Copy link

Description

Encountered a terminating error outside of IDE (VSCode) that I can't seem to get around. I did this issue posted before back in 2017-2018, but none of the solutions or checks that were discussed solved this problem. The repository used is PUPPET on my Github page, in case you want to reproduce the error. The full error is provided below:

terminate called after throwing an instance of 'nlohmann::detail::parse_error'
what(): [json.expection.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal

Reproduction steps

Strangely, it only occurs outside of the IDE, when calling the command json::parse(fstream ifs) or ifs >> json dict (the type is not called of course, it's just for reference). I don't think this is a bug with the library, but rather something I don't know when building it. I call the below build:

C:\msys64\mingw64\bin\g++.exe -fdiagnostics-color=always -g E:\Users\buzze\Documents\GitHub\PUPPET\.cpp\*.cpp -o E:\User\buzze\Documents\Github\PUPPET\puppet.exe -static.

I apologize if my information is unclear or lacking, or if this isn't a bug at all. Thank you for looking into this!

Expected vs. actual results

The expected result should load up the game menu, and allow the user to start a new game, resume a previous, select options, or exit. In particular, selecting options should be able to access and change the value(s) of the options.json file, but instead the program runs into the error and shuts down immediately.

Minimal code example

#include "../.hpp/json.hpp"
#include <fstream>

using namespace std;
using json = nlohmann::json;

int main() {
    ifstream ifs("../.json/options.json");
    json options = json::parse(ifs);

   return 0;
}

Error messages

terminate called after throwing an instance of 'nlohmann::detail::parse_error'
  what(): [json.expection.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal

Compiler and operating system

mingw64, Windows 10

Library version

3.10.5

Validation

@nlohmann
Copy link
Owner

nlohmann commented May 3, 2022

Can you please check if the working directory is properly set such that ../.json/options.json is an existing file? The error message indicates the file was not found. Maybe try an absolute path.

@jasonabuzzell
Copy link
Author

Ah thank you! It seems that VSCode's .exe launch.json started from the .cpp file level (${fileDurname}) and not from the working directory (${workspaceFolder}). This, in combination with using "../.json" instead of just ".json", caused a mismatch in where to look. Thanks again, no bug here at all!

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed kind: bug labels May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants