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:
在我的浏览器中查看url的结果时,我想打开Developer Tools javascript控制台并使用javascript命令来分析页面的结果。这是一个示例页面:
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.
注意 - 我正在更改此网址 - 烂番茄的网址不公开,我的密钥已过期。来自jsontest的这个例子与已接受的答案一起使用。
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.
有没有办法点击这个,启动firebug控制台(或在另一个浏览器中类似的东西)并解析这个json字符串,以便我可以使用常见的javascript来检查json对象。
EDIT
JQuery is not available...
JQuery不可用......
1 个解决方案
#1
11
In Chrome, I opened the link above and went to Chrome's Developer Tools (F12) and entered the following command in the console...
在Chrome中,我打开了上面的链接并转到Chrome的开发者工具(F12)并在控制台中输入以下命令...
JSON.parse(document.body.textContent)
It returns a the object representation quite nicely. From there is an easy matter to manipulate and play with the object in Javascript. For instance...
它很好地返回了一个对象表示。从Javascript中操作和使用对象是一件容易的事。例如...
JSON.parse(document.body.textContent).movies.length
...returns 2.
#1
11
In Chrome, I opened the link above and went to Chrome's Developer Tools (F12) and entered the following command in the console...
在Chrome中,我打开了上面的链接并转到Chrome的开发者工具(F12)并在控制台中输入以下命令...
JSON.parse(document.body.textContent)
It returns a the object representation quite nicely. From there is an easy matter to manipulate and play with the object in Javascript. For instance...
它很好地返回了一个对象表示。从Javascript中操作和使用对象是一件容易的事。例如...
JSON.parse(document.body.textContent).movies.length
...returns 2.