Skip to content

Allow exists method to handle out of bounds and wrong type errors#509

Merged
zhigang1992 merged 1 commit intoSwiftyJSON:masterfrom
jamesjn:exists-for-wrong-type-and-out-of-bounds
Sep 26, 2016
Merged

Allow exists method to handle out of bounds and wrong type errors#509
zhigang1992 merged 1 commit intoSwiftyJSON:masterfrom
jamesjn:exists-for-wrong-type-and-out-of-bounds

Conversation

@jamesjn
Copy link
Copy Markdown
Contributor

@jamesjn jamesjn commented May 12, 2016

Allow the exists method to handle out of bounds and wrong type errors by checking for errorValue.code == ErrorIndexOutOfBounds and errorValue.code == ErrorWrongType.

For example, when we have let jsonForArray = JSON([["number":1111]]) we would expect jsonForArray[1].exists() and jsonForArray["someValue"].exists() to return false.

I think the change here might fix the issue related to #498

@zhigang1992
Copy link
Copy Markdown
Contributor

Sweet, can you help solve the conflict here and let's ship this.

Sorry for not getting to this earlier.

@zhigang1992 zhigang1992 added this to the 3.1 milestone Sep 21, 2016
@jamesjn jamesjn force-pushed the exists-for-wrong-type-and-out-of-bounds branch from 72f326b to 356ebd2 Compare September 22, 2016 01:47
 - Check for out of bounds error on exists method
 - Check for wrong type error on exists method
 - Add tests for cases where out of bounds and wrong type errors occur
@jamesjn jamesjn force-pushed the exists-for-wrong-type-and-out-of-bounds branch from 356ebd2 to 78fb831 Compare September 22, 2016 02:04
@jamesjn
Copy link
Copy Markdown
Contributor Author

jamesjn commented Sep 22, 2016

@zhigang1992 Okay, rebased

@zhigang1992 zhigang1992 merged commit eee5bd9 into SwiftyJSON:master Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants