Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


arrayFromJSONWithError for NSData category #5

ahmetalpbalkan opened this Issue · 2 comments

2 participants


Along with this method:

// convenience method to ensure that top-level json object is a dictionary
- (id)dictionaryFromJSONWithError:(NSError **)error; // error pointer must not be nil

it would be really great if you provide arrayFromJSONWithError that internally calls this one and returns NSArray of NSDictionary instances from JSON, that would be good. I guess you also have such a need in 4sq API. Am I missing an obvious workaround?



Thank you for the suggestion; have added a method named arrayFromJSONWithError: in my personal fork at I will issue a pull request shortly.

However, you should note that both of these functions exist for the purpose of type safety: they parse the JSON and then check that the root object is of the expected type. Which one you use depends on what root type your API returns; every API I have ever seen (including the foursquare API) uses a dictionary as a root object, but arrays are certainly possible.

Your question suggests that there might be a conceptual misunderstanding; does this help clear things up?


Hi George. Thanks for quick response. We are on the same page about why these methods exist.

However, I think not all APIs provide dict as top level json objects in response. Well, most of them do so but there are certainly exceptions like some old-fashioned ones like Twitter:

I also created the same method with exact same contents for a quick workaround and it worked. Should be god to go then. Hopefully it gets merged, soon.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.