ユーザ用ツール

サイト用ツール


ejson

ejson

mongodb extended json

ejsonで出力

mongoexportを使うとejsonで出力される

mongoexport --db dbName --collection colName --query '{hoge:"yyyy"}' -o output.json

ejsonを読み込む

bsonモジュールのEJSON.parseを使う

const {EJSON} = require('bson')
const readline = require('readline')
const fs = require('fs')
 
 
const f = fs.createReadStream("output.json")
 
const rl = readline.createInterface(f, {})
 
rl.on("line", (line) => {
  const b = EJSON.parse(line, {legacy: true, relaxed: true})
  console.log(b);
})
ejson.txt · 最終更新: 2020/01/30 06:00 by nullpon