How to Separate HTML Response
I am using FConnect in my app. After the user logs in to his/her Facebook account I am getting his/her information as:
{
"id":"###########",
"name":"Vishnu Gupta",
"first_name":"Vishnu",
"last_name":"Gupta",
"link":"facebook a/c link id=#######",
"education":[{"school":{"id":"######"开发者_开发百科,"name":"st.joseph"},"type":"High School"}],
"gender":"male","email":"##########",
"timezone":5.5,
"locale":"en_US",
"verified":true,
"updated_time":"2010-11-27T10:10:25+0000"
}
I want to store user's information in database. To do that, I have to separate the user's information that is id, name, and email.
I tried using componentsSeparatedByString method but I do not understand how to retrieve the information in an array.
Can anyone help me????
The response you are getting is in JSON Format which basically have response in Array & Dictionary.
You will be getting this data in Dictionary..so you can access it by using the key value..
NSLog(@"%@",[NSDictionaryObject valueforkey:@"id"]); NSLog(@"%@",[NSDictionaryObject valueforkey:@"name"]); NSLog(@"%@",[NSDictionaryObject valueforkey:@"first_name"]);
Hope this will surely work for you.....
ya.....its corrrect.In detail: Add JSON SDK then write the below code
SBJSON *json = [[SBJSON alloc] init]; NSDictionary *returnObject = [json objectWithString:InfoName]; NSString @id=[NSString stringWithFormat:@"%@",[returnObject objectForKey:@"id"]]; same for name ,email.
then Add these objects to Array and release the json
JSOn is good to use for "key-value' pair parsing.
加载中,请稍侯......
精彩评论