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

{} and [] causes parser error. #352

Closed
smoofproof opened this issue Nov 5, 2016 · 4 comments
Closed

{} and [] causes parser error. #352

smoofproof opened this issue Nov 5, 2016 · 4 comments

Comments

@smoofproof
Copy link

Hey there!

{} and [] should be a valid empty JSON object/array. Instead, it creates - parse error - unexpected end of input.

Example:

nlohmann::json j;

std::stringstream ss("{}");

ss >> j;

Greetings

@boguscoder
Copy link

What version have you tried? I've tried both {} and [] and got expected result

#include <sstream>
#include <iostream>
#include "json.hpp"

using namespace nlohmann;

int main() {
    try {
        json j;
        std::stringstream ss("[]");
        ss >> j;
        std::cout << "all good" << std::endl;
    } catch(std::exception&) {
        std::cout << "no luck" << std::endl;
    }
}

@nlohmann
Copy link
Owner

nlohmann commented Nov 5, 2016

There was a bug with too short inputs in 2.0.6. Please try 2.0.7, see https://github.com/nlohmann/json/releases/tag/v2.0.7

@nlohmann
Copy link
Owner

@SmoofBullet Did you try the 2.0.7 version?

@smoofproof
Copy link
Author

Yes, i have tried the new version and the error disappeared. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants