is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface | mongodb在windows和Linux导出出错

执行mongoexport命令的时候

mongoexport --csv -f externalSeqNum,paymentId --host 127.0.0.1:27017 -d liveX -c consume_history -o 0531bill.csv -q '{"consumeStatus":"SUCCESS","externalSeqNum":/^201705/}'

报了异常

is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface

去掉-q和过滤条件是没有问题的,那么问题就出在过滤条件上

后来发现是window和linux的区别,linux上执行是外面包单引号,window要外面包双引号

window写错:"{'consumeStatus':'SUCCESS','externalSeqNum':/^201705/}" 就没有问题了

转自:https://blog.csdn.net/dzl84394/article/details/72879795