Skip to content

Getter is setting the value to null if the key does not exist #754

Description

@adityamarella

Here is the sample code

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

int main(void) {
    nlohmann::json json;
    json["xxx"] = 1;
    auto y = json["yyy"];
    std::cout << json.dump() << std::endl;
    return 0;
}

The output is {"xxx":1,"yyy":null}.

The expected behavior is to throw std::out_of_range exception

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions