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

Can't read json file #1791

Closed
AustinJia opened this issue Oct 15, 2019 · 3 comments
Closed

Can't read json file #1791

AustinJia opened this issue Oct 15, 2019 · 3 comments
Labels
kind: question solution: invalid the issue is not related to the library

Comments

@AustinJia
Copy link

AustinJia commented Oct 15, 2019

  • Describe what you want to achieve.
    Read .json file as json object

  • Describe what you tried.
    downloaded the include/nlohmann folder in my local project's include folder
    Create a .json file in src
    std::ifstream i(path+"config.json", std::ifstream::binary);
    json j;
    i >> j;
    it always shows

[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal

  • Describe which system (OS, compiler) you are using.
    ubuntu 16.04 xenial

  • Describe which version of the library you are using (release version, develop branch).
    JSON for Modern c++ v3.7.0

@nlohmann
Copy link
Owner

Why do you open the file in binary mode? Can you make sure it is properly opened (eg by piping the content to cout)?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Oct 15, 2019
@AustinJia
Copy link
Author

Thanks. You are right.
I opened the file with std::ifstream::in now
I even can't print out the content to cout.
Any idea?

@AustinJia
Copy link
Author

I figured out the issue, I was read the file from the build folder instead original folder.

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed state: needs more info the author of the issue needs to provide more details labels Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants