I have the following JSON:
{
0: 200,
error: false,
campaigns: {
current_campaigns: [
{
id: \"1150\",
campaign
The easiest thing to remember about JSON
is that every time you see a bracket "[", that means the beginning of an Array
and "]" is the end. Every time you see a curly brace "{" that means the beginning of a Dictionary
and "}" is the end.
So in your example, campaigns
is a Dictionary
element with another Dictionary
(current_campaigns
) that contains an Array
of Dictionaries
. Each of those Dictionaries
has a key
called title
.
So the long version (untested):
NSDictionary *campaigns = [dataDictionary objectForKey:@"campaigns"];
NSArray *currentCampaigns = [campaigns objectForKey:@"current_campaigns"];
for (NSDictionary *thisCampaign in currentCampaigns) {
NSLog(@"title: %@", [thisCampaign objectForKey:@"title"]);
}