iphone - Checking a null value from Json response in Objective-C -
[ { "at" : null, "ea" : null, "ad2" : "", "op" : null, "adslst" : [ ], "ems" : null, "nd" : { "mn" : null, "fn" : "sony", "ln" : "j" }, "zp" : "23456", "ct" : 1, "pp" : 0, "cid" : 161464, "pos" : null, "wpext" : null, "os" : 0, "hp" : "(345) 678-7890", "bttc" : 0, "pwd" : null, "uid" : 627, "did" : 0, "un" : null, "cy" : "salt lake", "comp" : null, "pmc" : 0, "aea" : null, "and" : null, "dob" : "1\/05\/1979", "idel" : false, "st" : "uh", "ad" : "2345 symonds street", "mob" : null, "wp" : "(234) 324-6576", "pl" : 0, "potcus" : false }, { "at" : null, "ea" : null, "ad2" : "", "op" : null, "adslst" : [ ], "ems" : null, "nd" : { "mn" : null, "fn" : "augustine", "ln" : "gomes" }, "zp" : "43567", "ct" : 1, "pp" : 0, "cid" : 161466, "pos" : null, "wpext" : null, "os" : 0, "hp" : "(456) 457-6588", "bttc" : 0, "pwd" : null, "uid" : 627, "did" : 0, "un" : null, "cy" : "test", "comp" : null, "pmc" : 0, "aea" : null, "and" : null, "dob" : null, "idel" : false, "st" : "az", "ad" : "2345 test", "mob" : null, "wp" : "(678) 987-0890", "pl" : 0, "potcus" : false }, { "at" : null, "ea" : null, "ad2" : "", "op" : null, "adslst" : [ ], "ems" : null, "nd" : { "mn" : null, "fn" : "jenny", "ln" : "x" }, "zp" : "45678", "ct" : 1, "pp" : 0, "cid" : 161467, "pos" : null, "wpext" : null, "os" : 0, "hp" : "(435) 644-6545", "bttc" : 0, "pwd" : null, "uid" : 627, "did" : 0, "un" : null, "cy" : "sallas", "comp" : null, "pmc" : 0, "aea" : null, "and" : null, "dob" : null, "idel" : false, "st" : "tx", "ad" : "2433 main street", "mob" : null, "wp" : "(657) 656-8798", "pl" : 0, "potcus" : false }, { "at" : null, "ea" : null, "ad2" : "", "op" : null, "adslst" : [ ], "ems" : null, "nd" : { "mn" : null, "fn" : "blvd cont f1", "ln" : "blvd contact l1" }, "zp" : "", "ct" : 1, "pp" : 0, "cid" : 161473, "pos" : null, "wpext" : null, "os" : 0, "hp" : null, "bttc" : 0, "pwd" : null, "uid" : 627, "did" : 0, "un" : null, "cy" : "", "comp" : null, "pmc" : 0, "aea" : null, "and" : null, "dob" : null, "idel" : false, "st" : "", "ad" : "", "mob" : null, "wp" : null, "pl" : 0, "potcus" : false },
in response want display "fn","ln","ct","pp","cid","pos","at","ea","ad2" these tag value.... null value want display "apple"....
can me
my code is
- (void)connectiondidfinishloading:(nsurlconnection *)connection { nserror *error; json = [nsjsonserialization jsonobjectwithdata:responsedata options:kniloptions error:&error]; nslog(@"json.... %@",json); id jsonobject = [nsjsonserialization jsonobjectwithdata:responsedata options:nsjsonreadingallowfragments error:nil]; nslog(@"jsonobject=%@", jsonobject); nsdictionary *checkarray=[jsonobject valueforkey:@"nd"]; chedisk=[checkarray valueforkey:@"fn"]; chedisk1=[checkarray valueforkey:@"ln"]; nslog(@"fn =%@",chedisk); nslog(@"ln =%@",chedisk1); }
null how nsnull singleton logs. so:
if (chedisk == [nsnull null]) { // chedisk null }
Comments
Post a Comment