hello,
right having issues parsing json application working on. using stig brautaset json classes attempt parse json google reader here's example:this code using parse it:code:{ "author": "harry", "continuation": "...", "direction": "ltr", "id": "user/userid/state/com.google/reading-list", "items": [ { "alternate": [ { "href": "http://www.test.com/article.html", "type": "text/html" } ], "annotations": [ ], "author": "", "categories": [ "cat1", "cat2" ], "comments": [ ], "crawltimemsec": "1332983007944", "id": "tag:google.com,2005:reader/item/90cd9acd9c62942f", "likingusers": [ ], "origin": { "htmlurl": "http://www.test.com", "streamid": "feed/http://www.test.com/rss.xml", "title": "test xml" }, "published": 1332982620, "summary": { "content": " amazing content", "direction": "ltr" }, "timestampusec": "1332983007944330", "title": "an amazing article", "updated": 1332982620 } ], "title": "harry's reading list in google reader", "updated": 1332983007 }which not working, returns error:code:#import "jsontestviewcontroller.h" #import "json.h" @implementation jsontestviewcontroller @synthesize responsedata; #pragma mark - #pragma mark fetch loans internet -(void)loaddata { self.responsedata = [nsmutabledata data]; nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/reading-list?ot=1253066400&r=n&xt=user/-/state/com.google/read&n=2&ck=1255660536125&client=myapplication"]]; [[nsurlconnection alloc] initwithrequest:request delegate:self]; } - (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response { [responsedata setlength:0]; } - (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { [responsedata appenddata:data]; } - (void)connection:(nsurlconnection *)connection didfailwitherror:(nserror *)error { [connection release]; self.responsedata = nil; } #pragma mark - #pragma mark process loan data - (void)connectiondidfinishloading:(nsurlconnection *)connection { [connection release]; nsstring *responsestring = [[nsstring alloc] initwithdata:responsedata encoding:nsutf8stringencoding]; self.responsedata = nil; nsarray* items = [(nsdictionary*)[responsestring jsonvalue] objectforkey:@"items"]; [responsestring release]; //choose random loan nsdictionary* item = [items objectatindex:1]; nsstring* name = [item objectforkey:@"title"]; //set text label label.text = name; //[nsstring stringwithformat:@"%@ - %@", name,author]; } @endi'm new json , can't seem figure out why isn't working, doing wrong?
help.
does json text validate?
google search terms: json validator
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment