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

Application terminating #830

Closed
lvkins opened this issue Nov 15, 2017 · 2 comments
Closed

Application terminating #830

lvkins opened this issue Nov 15, 2017 · 2 comments

Comments

@lvkins
Copy link

lvkins commented Nov 15, 2017

When I'm trying to run compiled application with simple parse code it fails with an exception:

[json.exception.parse_error.101] parse error at 73: syntax error - unexpected '}'; expected string literal

Code:

int main() {
    std::ifstream     file("test.json");
    std::stringstream buffer;
    buffer << file.rdbuf();

    json config;

    try {
        config = json::parse(buffer);
    } catch (const json::exception& e) {
        std::cout << "Loading error: " << e.what() << "\n";
        exit(-1);
    }

    try {
        std::cout << "Name: " << config["name"] << "\n";
    } catch (const json::exception& e) {
        std::cout << "Couldnt parse: " << e.what() << "\n";
        exit(-1);
    }
    return 0;
}

JSON file is indeed valid:

{
  "pi": 3.141,
  "happy": true,
  "name": "Niels",
  "nothing": null,
}

Compiler:

Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)

Bug or something I'm doing wrong?

@gregmarr
Copy link
Contributor

As the error says, the JSON file is invalid. You have a comma after null which doesn't belong.

@lvkins
Copy link
Author

lvkins commented Nov 15, 2017

Oh right. Been tired. Thanks.

@lvkins lvkins closed this as completed Nov 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants