I\'m using mongodb 2.2.0 and am trying to print json in a single line as opposed to \"pretty\" printing using printjson() or find().pretty(). i.e.
printjson()
find().pretty()
Try print(tojson()) - there's an example of printing using a cursor in the MongoDB docs.
print(tojson())
var myCursor = db.inventory.find( { type: 'food' } ); var myDocument = myCursor.hasNext() ? myCursor.next() : null; if (myDocument) { var myItem = myDocument.item; print(tojson(myItem)); }