官术网_书友最值得收藏!

Importing a JSON file into MongoDB

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:

./Applications/mongodb-3.0.4/bin/mongoimport --db pythonbicookbook --collection accidents --type json --headerline --file '/Data/Stats19-Data1979-2004/Accidents7904.json' --numInsertionWorkers 5
主站蜘蛛池模板: 大田县| 汽车| 保定市| 平和县| 四子王旗| 察隅县| 茌平县| 汝城县| 噶尔县| 互助| 桂东县| 迁安市| 波密县| 恩平市| 洛隆县| 惠水县| 运城市| 渭南市| 平邑县| 恩平市| 凯里市| 永昌县| 双峰县| 丰台区| 凤城市| 安仁县| 宝清县| 米脂县| 仁布县| 威宁| 辽阳市| 新晃| 牟定县| 沈丘县| 航空| 资兴市| 曲阜市| 桃源县| 株洲市| 姜堰市| 共和县|