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

Not existing value, crash #1065

Closed
DardanIljazi opened this issue Apr 23, 2018 · 1 comment
Closed

Not existing value, crash #1065

DardanIljazi opened this issue Apr 23, 2018 · 1 comment

Comments

@DardanIljazi
Copy link

DardanIljazi commented Apr 23, 2018

Bug Report

  • When I get a json list (from server) and that a value I try to reach doesn't exist, the application crash

Feature Request

  • I think that this kind of things shouldn't happen (maybe an error, or maybe something returning nothing would be better)

What is the best solution in this cases ? (Check before trying to get value ?..)

Edit

I didn't notice that:

note operator[] implements unchecked access for const objects: If the given key is not present, the behavior is undefined (think of a dereferenced null pointer) and yields an assertion failure if assertions are switched on. If you are not sure whether an element in an object exists, use checked access with the at() function.

@meirdavis
Copy link

I personally found .value(key, defaultValue) to be more useful, so I get a blank value back rather than an exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants