Skip to content

{} and [] causes parser error. #352

Closed

Description

@maleafl

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

Activity

  1. boguscoder commented on Nov 5, 2016

    @boguscoder

    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;
        }
    }
    
  2. nlohmann commented on Nov 5, 2016

    @nlohmann
    Owner

    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

  3. nlohmann commented on Nov 11, 2016

    @nlohmann
    Owner

    @SmoofBullet Did you try the 2.0.7 version?

  4. maleafl commented on Nov 14, 2016

    @maleafl
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions