6

When looking at the results of a url in my browser and I would like to open up the Developer Tools javascript console and use javascript commands to analyze the results of the page. Here's an example page:

http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=ju6z9mjyajq2djue3gbvv26t&q=deep&page_limit=2&page=1

Note - I'm changing the url for this - rotten tomatoes' URL isn't public and my key expired. This example from jsontest works with the accepted answer.

http://echo.jsontest.com/movies/ET

Is there a way to click on this, launch the firebug console (or something similar in another browser) and parse this json string so I could use common javascript to inspect the json object.

EDIT

JQuery is not available...

4

1 回答 1

18

在 Chrome 中,我打开上面的链接,然后转到 Chrome 的开发者工具 (F12),然后在控制台中输入以下命令...

JSON.parse(document.body.textContent)

它很好地返回了对象表示。从那里可以很容易地在 Javascript 中操作和使用对象。例如...

JSON.parse(document.body.textContent).movies.length

...返回 2。

于 2013-10-07T21:06:30.780 回答