gpt4 book ai didi

objective-c - -JSONValue 失败。错误是 : Illegal start of token [']

转载 作者:行者123 更新时间:2023-11-28 20:43:40 25 4
gpt4 key购买 nike

我从这里得到 json 字符串:http://vkontakte.ru/al_video.php?act=load_videos_silent&al=1&oid=8046830

我使用 Touch json 解析器。

//received json string from ASIHTTPRequest
NSString *responseString = [request responseString];
//removing all html elements like "br"
NSString *jsonString = [self decodeHTMLEntities:responseString];
//remove 4830<!><!>0<!>4316<!>0<!> this string at the beginning
jsonString = [jsonString stringByReplacingCharactersInRange:NSMakeRange(0, 25) withString:@""];
NSArray *arr = [jsonString JSONValue]
//And here is an error in Debug console: -JSONValue failed. Error is: Illegal start of token [']

如何解决?

最佳答案

我认为您必须将所有的 ' 替换为 "。JSON 通常不支持将 ' 作为标记定界符。

使用:

jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
jsonString = [jsonString stringByReplacingOccurrencesOfString:@"'" withString:@"\""];

关于objective-c - -JSONValue 失败。错误是 : Illegal start of token ['],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7349974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com