如何在Mongo脚本中打印到控制台对象?
我试过了:
> print({})
[object Object]
它只显示[object Object]
。以下哪项是console.dir()
的替代方案
发布于 2013-09-18 23:15:55
您可以使用printjson
来实现此目的:
> printjson({})
{ }
> printjson({a: 'foo', b: 'bar'})
{ "a" : "foo", "b" : "bar" }
发布于 2013-09-18 23:12:50
如果我只想看一下内容,我通常只会使用JSON.stringify()
。
> print ( JSON.stringify( { "foo": { "bar": "spam" } } ) )
https://stackoverflow.com/questions/18875962
复制相似问题