Note that there are some explanatory texts on larger screens.

plurals
  1. POSBJson Execptions after parsing (__NSArrayM objectForKey:)
    primarykey
    data
    text
    <p>I've some problems trying to parse Json using SBJson, I did some research and I can't find something helpfull...</p> <p>I followed some blog about how to do it, but I still get that error : "__NSArrayM objectForKey:"</p> <p>So this is the Json I'm trying to parse : </p> <pre><code>{ "result": [ { "authors": [ "Eric Ries" ], "bc": 9780671607, "title": "Yeah", "urlImage": "www.yeah.hey", "description": "Hey..." } ] } </code></pre> <p>This is the code I'm using : </p> <pre><code>SBJsonParser *json; NSDictionary *jsonResults; NSError *jsonError; json = [ SBJsonParser new ]; // Get result in a NSDictionary jsonResults = (NSDictionary*) [ json objectWithString:output error:&amp;jsonError ]; // Check if there is an error if (jsonResults == nil) { NSLog(@"Erreur lors de la lecture du code JSON (%@).", [ jsonError localizedDescription ]); } else { NSDictionary *book = (NSDictionary *)[ jsonResults objectForKey:@"result"]; NSArray *items = (NSArray *) [book objectForKey:@"title"]; } </code></pre> <p>The error : </p> <pre><code>-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x7a2d390 2012-11-19 20:32:36.336 FMS[500:11f03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM objectForKey:]: unrecognized selector sent to instance 0x7a2d390' *** First throw call stack: (0x2245012 0x16a3e7e 0x22d04bd 0x2234bbc 0x223494e 0x8c6a 0x36093 0xb39e83 0x2204376 0x2203e06 0x21eba82 0x21eaf44 0x21eae1b 0x219f7e3 0x219f668 0x8365c 0x2d6d 0x2c95) libc++abi.dylib: terminate called throwing an exception Current language: auto; currently objective-c </code></pre> <p>And by using valueForKey intead of objectForKey </p> <pre><code>[book valueForKey:@"title"]; </code></pre> <p>I'm getting this : </p> <pre><code>( "Yeah" ) </code></pre> <p>Instead of just Yeah</p> <p>And I don't want to parse again the ( "Yeah" ) to at least get Yeah...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload