在解析.json文件的内容时,像“ jamie's
”这样的字符串被表示为“ jamie 's
”任何人都知道为什么会这样?
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:@"'"
stringByReplacingOccurrencesOfString:@"@#039;" withString:@"'"
' ...
确保使用application / json作为内容类型将数据从服务器传输到客户端。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.