哪个字符串我通过我没有从网址获取数据?

时间:2014-04-17 06:51:46

标签: ios json parsing

所以我有这种格式的数据数据:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<string>{"Records":[{"id":26,"date":"05/04/2014","name":"A Summary of the US Dietary Guidelines"},{"id":27,"date":"05/04/2014","name":"Accompaniments"}]}</string>

如果这是我拥有的数据格式,我应该传递什么?

以下代码:

  NSString *Webservice_url = self.texturl.text;
NSLog(@"URL %@",Webservice_url);

// Create NSURL from string.
NSURL *Final_Url = [NSURL URLWithString:Webservice_url];

// Get NSData from Final_Url
NSData* data = [NSData dataWithContentsOfURL: Final_Url];

//parse out the json data
NSError* error;


// Use NSJSONSerialization class method. which converts NSData to Foundation object.
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data
                                                     options:kNilOptions error:&error];

// Create Array
NSArray* Response_array = [json objectForKey:@"Records"];
NSLog(@"Array: %@", Response_array);

self.arr1 = [Response_array valueForKey:@"id"];

NSLog(@" %@",self.arr1);

0 个答案:

没有答案