How can I print to console an object in a Mongo script?
I tried:
> print({}) [object Object]
It simply displays [object Object]
. Which is the alternative for console.dir()
?
You can use printjson
for that:
> printjson({}) { } > printjson({a: 'foo', b: 'bar'}) { "a" : "foo", "b" : "bar" }
If all I want to do is take a look at the contents, I'll usually just use JSON.stringify()
.
> print ( JSON.stringify( { "foo": { "bar": "spam" } } ) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With