iphone - create a json string from NSArray -
in iphone aplication have list of custom objects. need create json string them. how can implement sbjson or iphone sdk?
nsarray* eventsforupload = [app.dataservice.coredatahelper fetchinstancesof:@"event" where:@"isforupload" is:[nsnumber numberwithbool:yes]]; sbjsonwriter *writer = [[sbjsonwriter alloc] init]; nsstring *actionlinksstr = [writer stringwithobject:eventsforupload];
and empty result.
this process simple now, don't have use external libraries, way, (ios 5 & above)
nsarray *myarray; nsdata *jsondata = [nsjsonserialization datawithjsonobject:myarray options:nsjsonwritingprettyprinted error:&error]; nsstring *jsonstring = [[nsstring alloc] initwithdata:jsondata encoding:nsutf8stringencoding];
Comments
Post a Comment