json parsing in objective c
while parsing the content of a .json file, string lik开发者_JS百科e "jamie's
" is represented as "jamie 's
".Any one know why it is so?
Make sure you are using application/json as a content type to transfer the data from the server to the client.
You can also go through following link http://mobile.tutsplus.com/tutorials/iphone/iphone-json-twitter-api/
because the apostrophe is a special charachter and cant be transmitted inside of http packets. all special characters must be replaced with escape sequences like '
or with percent escapes %27 ...
in the NSString
class you will find the methods 'stringByReplacingPercentEscapesUsingEncoding:
' and 'stringByAddingPercentEscapesUsingEncoding:
' for handle percent escapes.
the escape sequencies you must handle by yourself for example with 'stringByReplacingOccurrencesOfString:@"@#039;" withString:@"'"
' ...
精彩评论