Skip to content

Check if a key exists #2191

Description

@tawmoto

Hi,

Is there a method to check if a key exists? Other than using .at() and catching the exception?
Sometimes I get a field named error in the json response and I would like to check it also.

Thanks.

Activity

  1. nlohmann commented on Jun 15, 2020

    @nlohmann
    Owner

    There is a contains(key) member function.

  2. tawmoto commented on Jun 15, 2020

    @tawmoto
    Author

    contains(key)

    Great, I don't know how I missed it. I was searching for "exists" or smth. :-)
    Thanks a lot!

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions