RSS 到 JSON、YQL

发布于 2024-11-18 20:10:21 字数 416 浏览 5 评论 0原文

我正在使用 yql 将 RSS 转换为 JSON,使用 查询。现在,让我恼火的是我得到了很好的文本响应(请参阅this了解其中的一小部分),但是,当我尝试使用 eval() (其可信代码)解析它时,它会窒息并显示 Unexpected token ":"。知道出了什么问题吗?

I'm converting RSS to JSON with yql, with this query. Now, what's irritating me is that I get the text response just fine (see this for a small part of it), but, when I try to parse it with eval() (its trusted code), it chokes and says Unexpected token ":". Any idea what's going wrong?

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

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

发布评论

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

评论(1

夜声 2024-11-25 20:10:21

您不需要使用 eval 解析 JSON - 有关详细信息,请参阅本文

您可以解析 JSON使用 Douglas Crockford 的 JSON 函数,可以从 github 下载。这应该可以解决任何令人头疼的评估问题。

因此,从上面的 github 页面下载 json2.js。将其包含在您的页面中,如下所示:

,然后使用以下方法解析您的 JSON 字符串:

var myJsonObject = JSON.parse( myJsonString);

You don't need to parse JSON with eval - see this article for more information

You can parse JSON using Douglas Crockford's JSON functions which can be downloaded from github here. This should solve any eval headaches.

So, download json2.js from the above github page. Include it in your page like this:

<script src="json2.js"></script>

and then parse your JSON string using:

var myJsonObject = JSON.parse(myJsonString);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文