[英]json parsing in objective c
在解析.json文件的内容时,像“ jamie's
”这样的字符串被表示为“ jamie 's
”任何人都知道为什么会这样?
because the apostrophe is a special charachter and cant be transmitted inside of http packets. 因为撇号是一个特殊的字符,不能在http数据包内传输。 all special characters must be replaced with escape sequences like '
所有特殊字符必须替换为转义序列,如'
or with percent escapes %27 ... 或%逃脱%27 ...
in the NSString
class you will find the methods ' stringByReplacingPercentEscapesUsingEncoding:
' and ' stringByAddingPercentEscapesUsingEncoding:
' for handle percent escapes. 在NSString
类中,您将找到方法' stringByReplacingPercentEscapesUsingEncoding:
'和' stringByAddingPercentEscapesUsingEncoding:
'for handle percent escapes。
the escape sequencies you must handle by yourself for example with ' stringByReplacingOccurrencesOfString:@"@#039;" withString:@"'"
您必须自己处理的转义序列,例如' stringByReplacingOccurrencesOfString:@"@#039;" withString:@"'"
stringByReplacingOccurrencesOfString:@"@#039;" withString:@"'"
' ... stringByReplacingOccurrencesOfString:@"@#039;" withString:@"'"
'......
确保使用application / json作为内容类型将数据从服务器传输到客户端。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.