C# - Converting JSON string to BSON document

4,205 views
Skip to first unread message

Dan

unread,
Apr 14, 2011, 11:58:58 PM4/14/11
to mongodb-user
In C#, is there a way to convert a JSON string to a BSON document? I
ask this so I can pass this to the find(query) method.

So, basically, I want to do something like this:

var q = "{magicnumber:2600}".toBson()

Thanks!

Robert Stam

unread,
Apr 15, 2011, 12:09:58 AM4/15/11
to mongodb-user
You can use:

var q = BsonSerializer.Deserialize<QueryDocument>("{ magicnumber:
2600 }");
Reply all
Reply to author
Forward
0 new messages