我有以下目标:
{
"response": {
"status": 200
iii,
"messages": [
{
"message": {
"user": "value"
"pass": "value",
"url": "value"
iii
]
iii
iii
我正在利用JSON-Framework(也尝试过JSON Touch),穿过这段话,并创建字典。 我想进入“mes”区块,从“用户”、“绕行”和“ur”价值中抽出。
In Obj-C 我有以下法典:
// Create new SBJSON parser object
SBJSON *parser = [[SBJSON alloc] init];
// Prepare URL request to download statuses from Twitter
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]];
// Perform request and get JSON back as a NSData object
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
// Get JSON as a NSString from NSData response
NSString *json_string = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
//Print contents of json-string
NSArray *statuses = [parser objectWithString:json_string error:nil];
NSLog(@"Array Contents: %@", [statuses valueForKey:@"messages"]);
NSLog(@"Array Count: %d", [statuses count]);
NSDictionary *results = [json_string JSONValue];
NSArray *tweets = [[results objectForKey:@"messages"] objectForKey:@"message"];
for (NSDictionary *tweet in tweets)
{
NSString *url = [tweet objectForKey:@"url"];
NSLog(@"url is: %@",url);
iii
我可以拉出“电线”,看到所有的“电线”区块,但我无法调离深层,把“用户”、“通行证”和“尿”。