ios - How do I urlencode this NSString that contains a JSON inside it? -
i have following json string should sent backend
{ id = "mu_200255802"; keywords = ( talk, games, meetup, time, meet, "time game" ); }
so before json have java servlet url like
http://....net/servletname?
how should urlencode json string , url because after trying several options, keep getting bad url error in delegate method. right way it/
i tried encoding using
nsstring *urlstringencoded = [[nsstring stringwithstring:urlstring] stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];
and used other encoding formats too.
use create json string
nserror *error; nsdata *jsondata = [nsjsonserialization datawithjsonobject:@"your object" options:nsjsonwritingprettyprinted error:&error]; nsstring *jsonstring = [[nsstring alloc] initwithdata:jsondata encoding:nsutf8stringencoding];
Comments
Post a Comment