json - SBJson Parse Data on iOS -
i want parse json has structure on ios, sbjson libs can me? much!
{"error":{"username":["the username has been taken."],"email":["the email has been taken."]}}
nsstring *str=@"{\"error\":{\"username\":[\"the username has been taken.\"],\"email\":[\"the email has been taken.\"]}}"; nsdata *data=[str datausingencoding:nsutf8stringencoding]; nsdictionary *json = [nsjsonserialization jsonobjectwithdata: data options: nsjsonreadingmutablecontainers error: nil]; nslog(@"dic %@",json);
//output
dic { error = { email = ( "the email has been taken." ); username = ( "the username has been taken." ); }; }
using sbjson
sbjson *parser = [[sbjson alloc] init]; nsdictionary *results = [str jsonvalue];
Comments
Post a Comment