How do I gracefully handle an (expected) nil keypath during a RestKit GET?
When I make a getAllEvents API call if the user doesn't have any events the API will return a null value in the payload, e.g. {"events":null}
. The null value causes the RestKit request: didFailLoadWithError
and objectLoader: didFailWithError
methods to be invoked, which I don't necessarily want because this is the expected behavior where there are 0 events. The error message it gives is Could not find an object mapping for keyPath: ''
.
Can I handle this in the mapping config and/or the delegate methods, or do I need to modify the API, perhaps to return an empty string instead of null. Is there a standard for what JSON should return when the list is empty?