admin管理员组

文章数量:1297077

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();

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();
Share edited May 23, 2017 at 11:52 CommunityBot 11 silver badge asked Dec 9, 2012 at 19:51 TyzakTyzak 2,4368 gold badges38 silver badges53 bronze badges 2
  • Is this in the mongo shell? – JohnnyHK Commented Dec 9, 2012 at 20:01
  • That is a javascript the I run with: mongo server:port/mydb --quiet /path/myscript.js – Tyzak Commented Dec 9, 2012 at 20:45
Add a ment  | 

1 Answer 1

Reset to default 7

You can use the tojson function like so:

str = tojson(db.mycol.stats());

本文标签: Convert Bson to stringMongoDBJavascriptStack Overflow