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

Check if a key exists #2191

Closed
tawmoto opened this issue Jun 15, 2020 · 2 comments
Closed

Check if a key exists #2191

tawmoto opened this issue Jun 15, 2020 · 2 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@tawmoto
Copy link

tawmoto commented Jun 15, 2020

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.

@nlohmann
Copy link
Owner

There is a contains(key) member function.

@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Jun 15, 2020
@tawmoto
Copy link
Author

tawmoto commented Jun 15, 2020

contains(key)

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

@tawmoto tawmoto closed this as completed Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants