Skip to content

Feature request :: Better testing for key existance without try/catch #1074

@mlfarrell

Description

@mlfarrell

Correct me if I'm wrong, but using a const json obj + .at() + try/catch is the only way safe to test for object key exists. This seems REALLY brutal compared to the ease of use using the rest of the library

Perhaps there'd be some way to return a bool operator comparable for object gets along the lines of

if(auto possibleVal = json["maybeExists"])
{
  //possibleVal exists
}

or.. at the very least, a .exists(const std::string &) method would be helpful..

Metadata

Metadata

Assignees

No one assigned

    Labels

    solution: proposed fixa fix for the issue has been proposed and waits for confirmation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions