tags:

views:

310

answers:

3

Hi there, I'm using ASIHTTP Request to get a NSString response that I give to a SBJSON parser.

The problem is that inside the NSString response I got some UTF8 encoded character (accent) that I need do decode to make the app works.

How can I decode UTF8 with JSON? I call the JSON message like this: [jsonParser objectWithString:jsonString error:NULL];

Any help would be so appreciated.

Fabrizio

+1  A: 

I just realized I didn't have to decode, the response is correctly read.

Thanx for reading.

Fabrizio

Fabrizio
+1  A: 

lol.... great ! but for more simplicity i will say.

Create new SBJSON parser object

SBJSON *parser = [[SBJSON alloc] init];

Prepare URL request to download statuses from Twitter

NSURLRequest *request = [NSURLRequest requestWithURL:
    [NSURL URLWithString:@"http://twitter.com/statuses/public_timeline.json"]];

Perform request and get JSON back as a NSData object

NSData *response = [NSURLConnection sendSynchronousRequest:request 
    returningResponse:nil error:nil];

Get JSON as a NSString from NSData response

NSString *json_string = [[NSString alloc] 
    initWithData:response encoding:NSUTF8StringEncoding];

Parse the JSON response into an object Here we're using NSArray since we're parsing an array of JSON status objects

NSArray *statuses = [parser objectWithString:json_string error:nil]

And in statuses array you have all the data you need.

yunas
A: 

I have a UTF-8 special characters in json response like ø (i.e. KKøss), when parsed with JSON it turned to \U00f8 (i.e. KK\U00f8ss). How should i convert it back to original string.

Adeesh