使用 Chrome 的开发工具调试 JSON

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16298379/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 19:43:25  来源:igfitidea点击:

Debugging JSON using Chrome's Dev Tools

jsondebugginggoogle-chrome-devtools

提问by Anthony

How do I access the resultsarray from the following page using Google Chrome's console?

如何使用 Google Chrome 的控制台从以下页面访问结果数组?

twitter.com/search.json?q=stackexchange

twitter.com/search.json?q=stackexchange

I keep getting this error:

我不断收到此错误:

ReferenceError: results is not defined

参考错误:结果未定义

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

采纳答案by Konrad Dzwinel

If what you really want is to browse this result set in a convinient way, just install one of JSON viewers for Chrome(preferably JSONView).

如果您真正想要的是以一种方便的方式浏览此结果集,只需为 Chrome安装一个 JSON 查看器(最好是JSONView)。

If you don't want to install any plugins, just run this:

如果您不想安装任何插件,只需运行以下命令:

JSON.parse($('.webkit-line-content').innerHTML);

in the console on page:

在页面上的控制台中:

view-source:https://search.twitter.com/search.json?q=stackexchange

回答by sreng

You can use console.debug()function in chrome console tab. example:

您可以console.debug()在 chrome 控制台选项卡中使用功能。例子:

console.debug(results)