Unable to view embedded objects in the new mongosh shell

There seems to be a pretty annoying difference in the new mongosh in comparison to the legacy mongo shell. I am wondering if there is an option to be able to set this to match the legacy shell or if I should open up a ticket

legacy shell:
{a: {b: {c: {d: {e: [{test:{test:“test”}}]}}}}}

   {
    	"a" : {
    		"b" : {
    			"c" : {
    				"d" : {
    					"e" : [
    						{
    							"test" : {
    								"test" : "test"
    							}
    						}
    					]
    				}
    			}
    		}
    	}
    }

Mongosh:
test = {a: {b: {c: {d: {e: [{test:{test:“test”}}]}}}}}

    {
      a: {
        b: {
          c: {
            d: { e: [ { test: [Object] } ] }
          }
        }
      }
    }

I suppose what is gained by readability is lost in introspection and reflection. I vastly prefer being able to view my embedded objects and take actions on them when necessary.

Has anyone found a workaround for this behavior?

Hello @Quest_Henkart!

https://docs.mongodb.com/mongodb-shell/reference/configure-shell-settings/ lists a bunch of settings – you can set inspectDepth to Infinity by running config.set('inspectDepth', Infinity). The settings is persisted, so if always getting the full output is what you prefer, it’s no problem to configure that.

(One additional note: I don’t know if this applies to you, but some people have asked for this in order to get machine-parseable output. Neither the output of mongosh nor of the legacy shell actually conform to a specific standard, so if this is your goal, we recommend that you use EJSON.stringify(value, null, 2) to print values as their full extended JSON representation, which is always machine-readable.)

I hope this helps!

6 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.