在用mongoexport导出的时候使用语句:
mongoexport -d flask -c tables1 -o test.json -q "{'modelName':'404'}"
一直报错Failed: error parsing query as Extended JSON: invalid JSON input
看了很多帖基本都是上述格式,尝试了各种单双引号搭配都没有用。后来在stackOverflow看到了有人问同样的问题,有人给出了解决方法:
其实所有的单引号都不能算是json格式,应该把语句中的单引号换成 ",即:
mongoexport -d flask -c tables1 -o test.json -q "{"modelName":"404"}
可以成功导出了:
2022-03-10T15:44:22.133+0800 connected to: mongodb://localhost/ 2022-03-10T15:44:22.167+0800 exported 1 record



