繁体   English   中英

在Json Parsing中解析双引号和单引号

[英]Parse double quotes and single quotes in Json Parsing

我正在解析JSON网址。 我得到的是\â\€\œ而不是单引号,并且是\â\€\而不是双引号。 在我的一端,我正在做NSUTF8StringEncoding但仍然没有得到单引号和双引号。

这是Web浏览器中的响应:

{“状态”:“ 1”,“数据”:[{“ id”:“ 1345”,“ title_en”:“”,“ content_en”:“妈妈说,\\ u00e2 \\ u20ac \\ u0153我喜欢这个。\\ u00e2 \\ u20ac \\ u009d \\ n \\ nJake说,\\ u00e2 \\ u20ac \\ u0153我不要\\ u00e2 \\ u20ac \\ u2122t得到它。\\ u00e2 \\ u20ac \\ u009d \\ n“,” image“:” 1396“,” pos“:” 2 “,” video_type“:” 0“,” video“:” 0“,” video_alt“:”“,” sound_type“:” 1“,” sound“:” 1123“,” sound_alt“:”“,”作者“:”“,” type“:” 0“,” book_id“:” 148“,” user_id“:” 24“,” title“:”艺术博物馆“,” author_url“:” maureen-d-1“ ,“ book_url”:“艺术博物馆”,“ video_filename”:“”,“ sound_filename”:“ atmuseum2.m4a”}]}

是否可以使用NSUTF8StringEncoding或其他方法解析以上响应。 或者我需要从PHP方面完成它。

您是否使用NSJSONSerialization? 在我的应用程序中,我这样做:

NSError* localError;
id jsonObjects = [NSJSONSerialization JSONObjectWithData:data
                                                 options:NSJSONReadingMutableContainers
                                                   error:&localError];

在“数据”变量中,我收到了服务器的响应。 我也从服务器接收UTF编码的文本(如\\ u00e2 \\ u20ac),但最终我得到了正常的字符串。 “ jsonObjects”将包含本机类型的数据:

    if ([jsonObjects isKindOfClass:[NSDictionary class]])
    {
        NSNumber* age = [jsonObjects objectForKey:@"age"];
    //...etc
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM