简体   繁体   English

Javascript-一个未知的JSON对象返回给我,我怎么看?

[英]Javascript - A unknown JSON object was returned to me, how do I look at it?

I'm having this situation. 我有这种情况。 In my FB.api call, a unknown JSON object was returned to me. 在我的FB.api调用中,一个未知的JSON对象返回给我。 I'm trying to figure out how to look into this JSON object! 我正在尝试弄清楚如何查看此JSON对象!

FB.api('/me/feed', 'post', wallPost , function(response) {
            if (!response || response.error) {
              alert('Error occured' + response);
            } else {
              alert('Post ID: ' + response);
            }
        });

Download firebug for firefox and put a breakpoint in that function and then hover over that variable and firebug should show you all of its properties and objects. 下载firebug的firebug,并在该函数中放置一个断点,然后将鼠标悬停在该变量上,firebug应该会向您显示其所有属性和对象。 Or use Chromes console to do the same thing 或使用Chrome控制台执行相同的操作

Try console.log(response) instead of alert. 尝试使用console.log(response)代替警报。 Then check the firebug console. 然后检查萤火虫控制台。

If you have firebug installed, do: 如果您安装了萤火虫,请执行以下操作:

console.log(response);

Then you can debug the structure of the JSON object using Firebug from the console-tab. 然后,您可以从控制台选项卡使用Firebug调试JSON对象的结构。

Just do a console.log of the data. 只需对数据进行console.log You can also iterate over its keys to look at each entry individually, or if you know some of them, just pick out those. 您还可以遍历其键以单独查看每个条目,或者,如果您知道其中的一些,只需挑选出来。

Remember to remove that console.log command after you tested your code. 测试代码后,请记住删除该console.log命令。 Browser with no support for this will complain. 不支持此功能的浏览器会抱怨。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM