2

how do I convert a bson obj to a string? I read Convert MongoDB BsonDocument into a string but that's for c#. I'm using Javascript for Mongodb

It would be applied at something like this:

myvar = db.mycol.stats();
2
  • Is this in the mongo shell? Commented Dec 9, 2012 at 20:01
  • That is a javascript the I run with: mongo server:port/mydb --quiet /path/myscript.js Commented Dec 9, 2012 at 20:45

1 Answer 1

7

You can use the tojson function like so:

str = tojson(db.mycol.stats());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.