我有几个 GB 从 RDBMS 导出为 JSON。所有日期都采用严格的 JSON 格式,即{$date:1354810746067}
.
Mongoimport 似乎没有将其转换为所需的 ISODate。只有当它被格式化为Date(1354810746067)
.
是否可以调整 mongoimport 以接受 {$date:..} 作为 ISODate?
sed
或者我应该通过一些脚本传递我的导入,也许?
样本输入就像
{cleared:true,category:"general auditing",transactionId:null,details:{new_terminal_mode:"test value-24",company_old_id:2534,new_terminal_state:"test value-28",reduction_type:"test value-3",transition_times:[{$date:1355408317000},{$date:1355407983000},{$date:1355413490000},{$date:1355411339000},{$date:1355414485000},{$date:1355414378000},{$date:1355408061000},{$date:1355408064000}]},_id:"69",dateTime:{$date:1354813457327},severity:20,eventType:"log_event_count_threshold_reached",systemId:693972591865925,carParkId:0}
我试过了
cat file | sed -e s/{$date:\([0-9]*\)}/Date\(\1\)/g | mongoimport -c test
但是我的正则表达式技能在那里失败了:-(。