mongodump failing with invalid json input mongodump failing with invalid json input
mongod --version
db version v3.4.1
git version: 5e103c4f5583e2566a45d740225dc250baacfbd7
OpenSSL version: OpenSSL 1.0.2n  7 Dec 2017
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1404
    distarch: x86_64
    target_arch: x86_64


/usr/bin/mongodump -u backup -p backup12345  --host=XX.XX.XX.XX --port XXXX --out=/tmp -d local -c oplog.rs --gzip --authenticationDatabase admin --query &quot;{'ts': { \$gt: Timestamp(1619548593, 1) } }&quot; --ssl --sslAllowInvalidCertificates

2021-04-28T01:21:37.694-0700    Failed: error parsing query as Extended JSON: invalid JSON input

anyone can figure what's the issue here ?
I understand that I'm using 3.4.1 which is older but still it is working on the other server and with same version. The same query runs perfectly alright on a different cluster node.
Also tried using the latest version of mongodump still the same error.
mongodb-database-tools-ubuntu1804-x86_64-100.3.1.tgz

I passed the same --query parameter as below in my command and I'm getting corresponding error
--query '{ &quot;ts&quot;: { &quot;$gt&quot;: Timestamp(1111111, 1) }}'


2021-04-28T11:10:01.328-0700    Failed: error parsing query as Extended JSON: error decoding key ts: invalid JSON input. Position: 17. Character: T

--query '{ &quot;ts&quot;: { &quot;$gt&quot;: ISODate(&quot;2021-04-05T08:00:00.000Z&quot;) }}'


2021-04-28T11:10:35.627-0700    Failed: error parsing query as Extended JSON: error decoding key ts: invalid JSON input. Position: 17. Character: I

--query &quot;{ 'ts': { \$gt:  ISODate(\&quot;2021-04-05T08:00:00.000Z\&quot;) }}&quot;


2021-04-28T11:11:20.797-0700    Failed: error parsing query as Extended JSON: invalid JSON input
Try adjusting the input:
/usr/bin/mongodump -u backup -p backup12345  --host=XX.XX.XX.XX --port XXXX --out=/tmp -d local -c oplog.rs --gzip --authenticationDatabase admin \
--query '{&quot;ts&quot;: { &quot;$gt&quot;: Timestamp(1619548593, 1) } }'
--ssl --sslAllowInvalidCertificates

I tried multiple versions and they worked fine with me:

--query '{ &quot;ts&quot;: { &quot;$gt&quot;: Timestamp(1111111, 1) }}'
--query '{ &quot;ts&quot;: { &quot;$gt&quot;: ISODate(&quot;2021-04-05T08:00:00.000Z&quot;) }}'
--query &quot;{ 'ts': { \$gt:  ISODate(\&quot;2021-04-05T08:00:00.000Z\&quot;) }}&quot;

In older mongo versions you need to use the &quot;extended json&quot;:

--query '{ &quot;ts&quot;: { &quot;$gt&quot;: {&quot;$timestamp&quot;:{&quot;t&quot;:1565545664,&quot;i&quot;:1}} }}'

this is completetly valid json and should work with the old client as well.
also see mongodump command with timestamp query