Hello All,
mongo outputs json in the following format…
root@124d7cfb725d:/# mongo --eval "db.adminCommand('listDatabases')"
MongoDB shell version v5.0.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("61ef35d1-7e31-43e1-87bb-e3f27405a1c1") }
MongoDB server version: 5.0.0
{
"databases" : [
{
"name" : "admin",
"sizeOnDisk" : NumberLong(40960),
"empty" : false
},
{
"name" : "config",
"sizeOnDisk" : NumberLong(12288),
"empty" : false
},
{
"name" : "local",
"sizeOnDisk" : NumberLong(40960),
"empty" : false
}
],
"totalSize" : NumberLong(94208),
"totalSizeMb" : NumberLong(0),
"ok" : 1
}
while mongosh in 5.0 does the following…
root@124d7cfb725d:/# mongosh --eval "db.adminCommand('listDatabases')"
Current Mongosh Log ID: 60fab3516abd6eae1265d3d6
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB: 5.0.0
Using Mongosh: 1.0.0
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
------
The server generated these startup warnings when booting:
2021-07-23T12:09:57.899+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2021-07-23T12:09:58.535+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------
{
databases: [
{ name: 'admin', sizeOnDisk: Long("40960"), empty: false },
{ name: 'config', sizeOnDisk: Long("61440"), empty: false },
{ name: 'local', sizeOnDisk: Long("40960"), empty: false }
],
totalSize: Long("143360"),
totalSizeMb: Long("0"),
ok: 1
}
I get the following error with an existing application…
Expecting property name enclosed in double quotes: line 2 column 3 (char 4)
It would be nice if the outputted json was parsable without further processing or at least an option to allow this.
Cheers,
Rhys