0

Every example I see uses some kind of driver (how to do it in C#/java/etc.) There's the tojson function but there isn't a tobson one.

How can I convert a json string to bson object in the MongoDB console?

2
  • 2
    Why would you want to convert JSON to a binary format in the shell? Commented May 15, 2013 at 19:40
  • I'm trying to do a bulk insert and it fails for json strings. I suspect it will work if I use an array of bson objects. Another application is to create a copy of an object. Commented May 15, 2013 at 21:08

1 Answer 1

1

You actually want to turn it into JSON so that you can insert it, not BSON.

This question has the answer as to how: Safely turning a JSON string into an object

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.