Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何打印以控制台 Mongo 脚本中的对象?
我试过了:
> print({}) [object Object]
它只是显示[object Object]. 哪个是替代品console.dir()?
[object Object]
console.dir()
您可以printjson为此使用:
printjson
> printjson({}) { } > printjson({a: 'foo', b: 'bar'}) { "a" : "foo", "b" : "bar" }
如果我只想看一下内容,我通常只会使用JSON.stringify().
JSON.stringify()
> print ( JSON.stringify( { "foo": { "bar": "spam" } } ) )