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 object from std::ifstream #315

Closed
ghost opened this issue Sep 23, 2016 · 3 comments
Closed

json object from std::ifstream #315

ghost opened this issue Sep 23, 2016 · 3 comments
Labels
solution: invalid the issue is not related to the library

Comments

@ghost
Copy link

ghost commented Sep 23, 2016

I'm trying to initialise a json object from file.
using json = nlohmann::json;
std::ifstream file("Config.json");
json object(file);

I get the following error on terminal

terminate called after throwing an instance of 'std::invalid_argument' what(): parse error - unexpected '�'; expected string literal

And following warning on output

Main.cpp:31:21: warning: ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::basic_json(std::istream&, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::parser_callback_t) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; std::istream = std::basic_istream; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType>::parser_callback_t = std::function<bool(int, nlohmann::basic_json<>::parse_event_t, nlohmann::basic_json<>&)>]’ is deprecated (declared at libs/json.hpp:1945) [-Wdeprecated-declarations]
json object(file);

I'm using g++ (Ubuntu 4.9.4-2ubuntu1~12.04) 4.9.4 for compiling.
C++11 is enabled.

Am I doing something wrong?

@ghost
Copy link
Author

ghost commented Sep 23, 2016

The quotation marks in Config.json were wrong kind. Works now.

@ghost ghost closed this as completed Sep 23, 2016
@nlohmann nlohmann added the solution: invalid the issue is not related to the library label Oct 2, 2016
@kariya2
Copy link

kariya2 commented Oct 8, 2017

Hey I am facing the same issue, could you please tell me what you did to fix it?

@nlohmann
Copy link
Owner

nlohmann commented Oct 8, 2017

@kariya2 How does your JSON file look like? What exception do you get while parsing it?

This issue was closed.
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