JavaScript Object Notation (JSON) is becoming the number one format for data exchange on the Web. Modern REST APIs return data in the JSON format, and MongoDB stores the records as binary-encoded JSON documents called BSON. Use the following recipe to import JSON documents into MongoDB.
Getting ready
As we've done in previous import recipes, we'll be using the mongoimport utility to import the data in the JSON file into MongoDB. By default, mongoimport expects a JSON file unless told otherwise.
How to do it…
The command for importing a JSON file is almost the same as we used for importing a CSV file: