TouchXML 使用不带引号的键解析响应

发布于 2024-10-07 15:53:03 字数 185 浏览 0 评论 0原文

有没有办法使用 TouchXML 来解析 json,其中密钥没有被引用,如下所示:

{ foo:"bar" }

我正在尝试解析来自 web 服务(google)的响应,因此简单地将 JSON 代码修复为有效不是一个选项。

如果不可能,有没有办法有效地引用键作为预处理步骤?

Is there a way to use TouchXML to parse json in which the key are not quoted, like this:

{ foo:"bar" }

I'm trying to parse the response from a webservice (google), so simply fixing the JSON code to be valid is not an option.

If it's not possible, is there a way to efficiently quote the keys as a preprocessing step?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹苦笑 2024-10-14 15:53:03

我决定使用 RegexKitLite 对其进行预解析,使用

uint numReplace = [encoded replaceOccurrencesOfRegex:@"(?<=[\\{,])[^:\\[\\{\"]+(?=:)" withString:@"\"$0\""];

I decided to pre-parse it with RegexKitLite, using

uint numReplace = [encoded replaceOccurrencesOfRegex:@"(?<=[\\{,])[^:\\[\\{\"]+(?=:)" withString:@"\"$0\""];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文