views:

205

answers:

2

I'm using cocoa JSON framework http://code.google.com/p/json-framework/

Here is the result of an JSON output that I get. I can see that results in dictionary

Response {
"completed_in" = 0.02461;
"max_id" = 10088639298;
"next_page" = "?page=2&max_id=10088639298&q=apple";
page = 1;
query = apple;
"refresh_url" = "?since_id=10088639298&q=apple";
results =     (
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:09 +0000";
        "from_user" = leduxcwb;
        "from_user_id" = 69744637;
        geo = <null>;
        id = 10088639298;
        "iso_language_code" = pt;
        "profile_image_url" = "http://a3.twimg.com/profile_images/459490475/Backup_of_Ledux_LOGO_FUNDO_2_normal.jpg";
        source = "&lt;a href=&quot;http://echofon.com/&amp;quot; rel=&quot;nofollow&quot;&gt;Echofon&lt;/a&gt;";
        text = "FOTOS NOVAS - B-DAY Apple Carraro @applecarraro com @smccarraro @letsdoitbetter Bogus e muito mais - LEDUXcwb - http://bit.ly/9W2GOn";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:09 +0000";
        "from_user" = BIEBERBAABY;
        "from_user_id" = 87598715;
        geo = <null>;
        id = 10088639165;
        "profile_image_url" = "http://a3.twimg.com/profile_images/736057781/lmaaao__angell_muucch_normal.jpg";
        source = "&lt;a href=&quot;http://twitter.com/&amp;quot;&amp;gt;web&amp;lt;/a&amp;gt;";
        text = "RT @justinbieber: BABY - http://itunes.apple.com/us/album/baby-feat-ludacris-single/id350389778";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:08 +0000";
        "from_user" = TheFerstFamily;
        "from_user_id" = 5186275;
        geo = <null>;
        id = 10088638658;
        "iso_language_code" = en;
        "profile_image_url" = "http://a1.twimg.com/profile_images/80538644/Sherri_and_Tom_normal.jpg";
        source = "&lt;a href=&quot;http://apiwiki.twitter.com/&amp;quot; rel=&quot;nofollow&quot;&gt;API&lt;/a&gt;";
        text = "Apple &amp; Honeysuckle Refreshing Body Spray  30% off and free shipping http://tinyurl.com/yapqsqf at Bonanzle.";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:07 +0000";
        "from_user" = nappypoet;
        "from_user_id" = 3727061;
        geo = <null>;
        id = 10088638027;
        "iso_language_code" = en;
        "profile_image_url" = "http://a3.twimg.com/profile_images/603999315/DSCN1910_normal.JPG";
        source = "&lt;a href=&quot;http://m.twitter.com/&amp;quot; rel=&quot;nofollow&quot;&gt;mobile web&lt;/a&gt;";
        text = "APPLE STORE!!!!!!!!!!!!";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:06 +0000";
        "from_user" = morningnew;
        "from_user_id" = 90568021;
        geo = <null>;
        id = 10088637474;
        "iso_language_code" = en;
        "profile_image_url" = "http://a1.twimg.com/profile_images/632625890/11238_1187063001649_1380523419_30571850_5695474_n_normal.jpg";
        source = "&lt;a href=&quot;http://apiwiki.twitter.com/&amp;quot; rel=&quot;nofollow&quot;&gt;API&lt;/a&gt;";
        text = "latest video clip Chile, test and keep brand new APPLE iPad here http://bit.ly/ctyW2C [CA people Only]";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:05 +0000";
        "from_user" = "MaddieT_Love";
        "from_user_id" = 36657123;
        geo = <null>;
        id = 10088637057;
        "iso_language_code" = en;
        "profile_image_url" = "http://a3.twimg.com/profile_images/672448029/zzz____normal.jpg";
        source = "&lt;a href=&quot;http://www.myspace.com/sync&amp;quot; rel=&quot;nofollow&quot;&gt;MySpace&lt;/a&gt;";
        text = "TELLiNG OFF KiERSTEN!!!! haha &quot;if yu painted her red,, she'd be a GIANT apple!!!!&quot; (:";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:04 +0000";
        "from_user" = TechPsychic;
        "from_user_id" = 65162673;
        geo = <null>;
        id = 10088636187;
        "iso_language_code" = en;
        "profile_image_url" = "http://a1.twimg.com/profile_images/449688160/dragon_normal.jpg";
        source = "&lt;a href=&quot;http://apiwiki.twitter.com/&amp;quot; rel=&quot;nofollow&quot;&gt;API&lt;/a&gt;";
        text = "Apple announced a beta Launch a status online is trying to which has.";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:03 +0000";
        "from_user" = sallyroyerderr;
        "from_user_id" = 15188311;
        geo = <null>;
        id = 10088635728;
        "iso_language_code" = en;
        "profile_image_url" = "http://a3.twimg.com/profile_images/616259477/IMG_2013_normal.jpg";
        source = "&lt;a href=&quot;http://twitter.com/&amp;quot;&amp;gt;web&amp;lt;/a&amp;gt;";
        text = "Apple cake and coffee...delicious!";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:35:02 +0000";
        "from_user" = "steve_widen";
        "from_user_id" = 93551780;
        geo = <null>;
        id = 10088634985;
        "iso_language_code" = en;
        "profile_image_url" = "http://a1.twimg.com/profile_images/664143910/stevetweet_normal.jpg";
        source = "&lt;a href=&quot;http://www.hootsuite.com&amp;quot; rel=&quot;nofollow&quot;&gt;HootSuite&lt;/a&gt;";
        text = "Apple's Academy Award For Product Placement | http://ow.ly/1f3dD";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:34:58 +0000";
        "from_user" = LessiaFetsch;
        "from_user_id" = 100092422;
        geo = <null>;
        id = 10088633257;
        "iso_language_code" = ru;
        "profile_image_url" = "http://a3.twimg.com/profile_images/669973111/4_normal.jpg";
        source = "&lt;a href=&quot;http://twitter.com/&amp;quot;&amp;gt;web&amp;lt;/a&amp;gt;";
        text = "\U043f\U043e\U0434\U0430\U0440\U0438\U043b\U0438 apple magic mouse, \U0441\U0438\U0436\U0443 \U043b\U043e\U043c\U0430\U044e \U0433\U043e\U043b\U043e\U0432\U0443,\U043a\U0430\U043a \U0436 \U0435\U0451 \U043d\U0430\U0441\U0442\U0440\U043e\U0438\U0442\U044c :D \U043d\U0443 \U0434\U0430,\U044f \U0447\U0430\U0439\U043d\U0438\U043a \U0438 \U0447\U0442\U043e :D";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:34:57 +0000";
        "from_user" = "I_Dont_Cin";
        "from_user_id" = 80004560;
        geo = <null>;
        id = 10088632392;
        "iso_language_code" = en;
        "profile_image_url" = "http://a3.twimg.com/profile_images/735462983/I_Dont_Cin_normal.jpg";
        source = "&lt;a href=&quot;http://echofon.com/&amp;quot; rel=&quot;nofollow&quot;&gt;Echofon&lt;/a&gt;";
        text = "RT @girlKell: these sour apple bitter bitches im not fucking with them";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:34:54 +0000";
        "from_user" = maddenkatie;
        "from_user_id" = 80572995;
        geo = <null>;
        id = 10088631073;
        "profile_image_url" = "http://a1.twimg.com/profile_images/712744500/19150_1342329082633_1363398519_30948030_6001641_n_normal.jpg";
        source = "&lt;a href=&quot;http://twitter.com/&amp;quot;&amp;gt;web&amp;lt;/a&amp;gt;";
        text = "RT @justinbieber: BABY - http://itunes.apple.com/us/album/baby-feat-ludacris-single/id350389778";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:34:54 +0000";
        "from_user" = SirKnowsALot;
        "from_user_id" = 90229447;
        geo = <null>;
        id = 10088630768;
        "iso_language_code" = en;
        "profile_image_url" = "http://s.twimg.com/a/1267816830/images/default_profile_5_normal.png";
        source = "&lt;a href=&quot;http://apiwiki.twitter.com/&amp;quot; rel=&quot;nofollow&quot;&gt;API&lt;/a&gt;";
        text = "http://ow.ly/WEWQ I wrote a tutorial called How to create iPhone ringtones using only iTunes. It's not that hard. #apple #mp3 #aac #free";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:34:39 +0000";
        "from_user" = ronbentata;
        "from_user_id" = 51909217;
        geo = <null>;
        id = 10088623134;
        "iso_language_code" = en;
        "profile_image_url" = "http://a3.twimg.com/profile_images/544679831/IMG_3998_z_normal.jpg";
        source = "&lt;a href=&quot;http://www.linkedin.com/&amp;quot; rel=&quot;nofollow&quot;&gt;LinkedIn&lt;/a&gt;";
        text = "Apple's stock reaches a new high - almost $220. wish i have a few (a lot actually)";
        "to_user_id" = <null>;
    },
            {
        "created_at" = "Sat, 06 Mar 2010 20:34:38 +0000";
        "from_user" = MikaylaFenty;
        "from_user_id" = 70426321;
        geo = <null>;
        id = 10088622471;
        "profile_image_url" = "http://a3.twimg.com/profile_images/722158465/selena_gomez_normal.jpg";
        source = "&lt;a href=&quot;http://twitter.com/&amp;quot;&amp;gt;web&amp;lt;/a&amp;gt;";
        text = "RT @justinbieber: BABY - http://itunes.apple.com/us/album/baby-feat-ludacris-single/id350389778";
        "to_user_id" = <null>;
    }
);
"results_per_page" = 15;
"since_id" = 0;

}

Here is what NSLog says when I do [obj class] on the object.

2010-03-06 15:37:30.730 LuckyNumbers[61219:207] Current Object type: NSCFString object: query
2010-03-06 15:37:30.731 LuckyNumbers[61219:207] Current Object type: NSCFString object: since_id
2010-03-06 15:37:30.732 LuckyNumbers[61219:207] Current Object type: NSCFString object: next_page
2010-03-06 15:37:30.733 LuckyNumbers[61219:207] Current Object type: NSCFString object: completed_in
2010-03-06 15:37:30.734 LuckyNumbers[61219:207] Current Object type: NSCFString object: results
2010-03-06 15:37:30.736 LuckyNumbers[61219:207] Current Object type: NSCFString object: max_id
2010-03-06 15:37:30.737 LuckyNumbers[61219:207] Current Object type: NSCFString object: page
2010-03-06 15:37:30.737 LuckyNumbers[61219:207] Current Object type: NSCFString object: results_per_page
2010-03-06 15:37:30.738 LuckyNumbers[61219:207] Current Object type: NSCFString object: refresh_url

How do I get the full Dictionary of results?

+3  A: 

That's not valid JSON syntax; it's vaguely close but it's also very wrong. I'm not exactly sure what you're asking here, however.

Pointy
I believe the questioner logged the parsed object, which would be a property list. It's valid property-list syntax.
Peter Hosey
That makes sense to me; however the question is phrased as if that's the JSON itself.
Pointy
+1  A: 

Are you doing this?

NSArray *array = /*can has object from JSON kplzthx*/;
for (id obj in array) {
    NSLog(@"Current Object type: %@; object: %@", [obj class], obj);
}

The result of the parse is not an array, it's a dictionary, whose keys are @"completed_in", @"max_id", etc. Those keys are what you're getting in this loop: Looping on a dictionary yields its keys (not in any specific order).

Note that telling the compiler that the variable will hold a pointer to an NSArray does not mean it will; if the above resembles your code, then you are putting a pointer to an NSDictionary (which the JSON parser created and returned to you) into that variable. The compiler has no way to predict this; it can do nothing but believe what you tell it.

It's not clear exactly what you want. If you meant to loop on the array of result dictionaries, then ask the dictionary that the JSON parser returned to you for the object for the key @"results"; that object will be the array of dictionaries.

If you meant to simply get the top-level dictionary representing the complete parse of the JSON data: Congratulations; you have it. It's the object the JSON parser returned to you.

Or, in code:

NSDictionary *topLevelDictionary = /*object from JSON parser*/;
NSArray *resultDictionaries = [topLevelDictionary objectForKey:@"results"];
Peter Hosey