I need to write the equivalent to this php code
json_encode(utf8_encode())
in objective-c
I\'ve implemented the equivalent to utf8
You could have a look at
+ (NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError **)error
You get back JSON data from some object of Apples Foundation classes. If you need a string, you could use:
- (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding
of NSString. Might result in something like:
NSString *string = [[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:YOUR_OBJECT_HERE options:0 error:nil] encoding:NSUTF8StringEncoding] autorelease];