打印 JSON 解析的对象? [英] Print JSON parsed object?

查看:36
本文介绍了打印 JSON 解析的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 javascript 对象,它已经使用 JSON.parse 进行了 JSON 解析,我现在想打印该对象,以便我可以调试它(函数出了点问题).当我执行以下操作时...

I've got a javascript object which has been JSON parsed using JSON.parse I now want to print the object so I can debug it (something is going wrong with the function). When I do the following...

for (property in obj) {
    output += property + ': ' + obj[property]+'; ';
}
console.log(output);

我列出了多个 [object Object].我想知道如何打印它以查看内容?

I get multiple [object Object]'s listed. I'm wondering how would I print this in order to view the contents?

推荐答案

大多数调试器控制台都支持直接显示对象.就用

Most debugger consoles support displaying objects directly. Just use

console.log(obj);

根据您的调试器,这很可能会在控制台中将对象显示为折叠树.您可以打开树并检查对象.

Depending on your debugger this most likely will display the object in the console as a collapsed tree. You can open the tree and inspect the object.

这篇关于打印 JSON 解析的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆