-1

I have some code where i using yajl parser:

NSArray *JSONArray = [tempContainer yajl_JSON];
NSLog(@"array of json is = %@",JSONArray);  

and after parsing i got some json data like

{ 
  "account_number": "123", 
  "some_stuff": "231",
}

My question is next: how i get data from specific value of parsed data.

*ex. i want "account_number" , and i get "123"*

Vlad Z.
  • 3,401
  • 3
  • 32
  • 60

2 Answers2

0

Your question should be clear and without typo

Are you sure you are getting json data in the same format as you typed in your question or it just a typo?

I assume your json data is like { "account_number": "123", "some_stuff": 231, }

then its just a simple dictionary and you can get the value using valueForKey method.

Praveen-K
  • 3,401
  • 1
  • 23
  • 31
0

You may want to look into the streaming API to build NSMutableDictionaries from JSON:

NSData *data = [NSData dataWithContentsOfFile:@"example.json"];

 YAJLParser *parser = [[YAJLParser alloc] initWithParserOptions:YAJLParserOptionsAllowComments];
 parser.delegate = self;
 [parser parse:data];
 if (parser.parserError)
   NSLog(@"Error:\n%@", parser.parserError);

 parser.delegate = nil;
 [parser release];

 // Include delegate methods from YAJLParserDelegate 
 - (void)parserDidStartDictionary:(YAJLParser *)parser { }
 - (void)parserDidEndDictionary:(YAJLParser *)parser { }

 - (void)parserDidStartArray:(YAJLParser *)parser { }
 - (void)parserDidEndArray:(YAJLParser *)parser { }

 - (void)parser:(YAJLParser *)parser didMapKey:(NSString *)key { }
 - (void)parser:(YAJLParser *)parser didAdd:(id)value { }
Cliff
  • 10,586
  • 7
  • 61
  • 102