title: mongoexport - issue with JSON query (extended JSON - Invalid JSON input)
body: <p>I have started learning MongoDB recently. Today the instructor taught us the <strong>mongoexport</strong> command. While practicing the same, I face a typical issue which none of the other batchmates including the instructor faced. I use <strong>MongoDB version 4.2.0</strong> on my <strong>Windows 10</strong> machine. </p>
  
  <p>If I use mongoexport for my collection without any -q parameter to specify any filtering condition, it works fine.  </p>
  
  <pre><code>mongoexport -d trainingdb -c employee -f empId,name,designation -o \mongoexport\all-employees.json
  
  2019-09-17T18:00:30.300+0530    connected to: mongodb://localhost/
  2019-09-17T18:00:30.314+0530    exported 3 records
  </code></pre>
  
  <p>However, whenever I specify the JSON query as -q (or --query) it gives an error as follows.</p>
  
  <pre><code>mongoexport -d trainingdb -c employee -f empId,name,designation -q {'designation':'Developer'} -o \mongoexport\developers.json
  
  2019-09-17T18:01:45.381+0530    connected to: mongodb://localhost/
  2019-09-17T18:01:45.390+0530    Failed: error parsing query as Extended JSON: invalid JSON input
  </code></pre>
  
  <p>The same error persists in all the different flavors I had attempted with for the query.</p>
  
  <pre><code>-q {'designation':'Developer'}
  --query {'designation':'Developer'}
  -q "{'designation':'Developer'}"
  </code></pre>
  
  <p>I had even attempted with a different query condition on the 'empId' as -q {'empId':'1001'} But no luck. I keep getting the same error. </p>
  
  <p>As per <a href="https://stackoverflow.com/a/34394870/1001242">one of the suggestions given in the StackOverflow website</a>, I tried with the following option but getting a different error.</p>
  
  <pre><code>  -q '{"designation":"Developer"}'
  </code></pre>
  
  <p>The error is :  '<em>query '[39 123 101 109 112 73 100 58 49 48 48 49 125 39]' is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface {}</em>'.</p>
  
  <pre><code>2019-09-17T20:24:58.878+0530    query '[39 123 101 109 112 73 100 58 49 48 48 49 125 39]' is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface {}
  2019-09-17T20:24:58.882+0530    try 'mongoexport --help' for more information
  </code></pre>
  
  <p>I am really not sure what is missing here ? Tried with a bit of Googling and also gone through the official <a href="https://docs.mongodb.com/manual/reference/program/mongoexport/" rel="noreferrer">MongoDB documentation of the mongoexport</a> - but no luck. </p>
  
  <p>The employee collection in my system looks like the follows with 3 documents.</p>
  
  <pre><code>&gt; db.employee.find().pretty()
  {
          "_id" : ObjectId("5d80d1ae0d4d526a42fd95ad"),
          "empId" : 1001,
          "name" : "Raghavan",
          "designation" : "Developer"
  }
  {
          "_id" : ObjectId("5d80d1b20d4d526a42fd95ae"),
          "empId" : 1002,
          "name" : "Kannan",
          "designation" : "Architect"
  }
  {
          "_id" : ObjectId("5d80d1b40d4d526a42fd95af"),
          "empId" : 1003,
          "name" : "Sathish",
          "designation" : "Developer"
  }
  &gt;
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>As suggested by @NikosM, I have saved the query in a .json file (<strong>query.json</strong>) and tried the same mongoexport command with the new approach. Still, no luck. Same Marshal error. </p>
  
  <pre><code>cat query.json
  {"designation":"Developer"}
  
  mongoexport -d trainingdb -c employee -f empId,name,designation -q 'query.json' -o \mongoexport\developers.json
  
  2019-09-17T21:16:32.849+0530    query '[39 113 117 101 114 121 46 106 115 111 110 39]' is not valid JSON: json: cannot unmarshal string into Go value of type map[string]interface {}
  2019-09-17T21:16:32.852+0530    try 'mongoexport --help' for more information
  </code></pre>
  
  <p>Any help on this will be highly appreciated. </p>