How can you deserialize an escaped JSON string with NSJSONSerialization?

后端 未结 4 1180
名媛妹妹
名媛妹妹 2020-12-03 05:21

I have an iOS app that needs to process a response from a web service. The response is a serialized JSON string containing a serialized JSON object, looking something like t

4条回答
  •  失恋的感觉
    2020-12-03 06:07

    Just cut off the leading and trailing quotes and then replace all \"s with ":

    NSString *sub = [original substringWithRange:(NSRange){ 1, original.length - 2 }];
    NSString *unescaped = [sub stringByReplacingOccurrencesOfString:@"\\\" withString:@"\"];
    

提交回复
热议问题