有没有办法设置 MongoDB 的 pretty
shell 命令的缩进级别?
有时,在 pretty-print 时需要包装深层嵌套的对象。而模块如 Python's pprint有一个缩进级别设置,MongoDB's pretty
API似乎没有提供这个。
有没有解决方法(任何方法来设置 pretty-print 的缩进)?
最佳答案
如the mongo shell是一个JavaScript shell,你可以use its pretty-printing functionality 。例如
JSON.stringify(db.runs.find()[0], null, 2)
JSON.stringify
的第三个参数
indicates the number of space characters to use as white space;
关于mongodb - 在 mongo shell 中设置 pretty-print 的缩进级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45052363/