在控制台中展开对象
我正在 console.log
ing 一些 JSON,默认情况下 Google Chrome 会包装整个对象。因此,如果我想获得 JSON 中内容的全局视图,我必须手动递归地解开每个属性。是否可以告诉 console.log
我希望我的对象完全展开?
I am console.log
ing some JSON and Google Chrome by default has the whole object wrapped. So if I want to have a global view of the stuff in the JSON, I have to manually unwrap every property reccursively. Is it possible to tell console.log
that I want my object to be completely unwrapped?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
console.dir
和console.log
以这种方式包装对象,因此它们不必处理会导致无限循环的递归。我不相信有办法让它用特殊命令打开整个对象(出于上述原因)。您可以将 JSON 重新字符串化为“漂亮”,并将整个内容作为字符串查看:
唯一的其他选择是将 JSON 粘贴到 JSON 查看应用程序中(Fiddler 有一个内置的)。
console.dir
andconsole.log
wrap objects in that manner so they don't have to deal with recursion, which would cause an infinite loop. I don't believe there's a way to have it unwrap the entire object (for the aforementioned reason) with a special command.You could restringify the JSON to be "pretty" and view the entire thing as a string:
The only other option is to paste your JSON into a JSON viewing application (Fiddler has one built in).