diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-03-26 16:16:53 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-03-26 16:16:53 -0400 |
commit | c4c2b2559a94d4fe0859c6a25aea5c994b39e6f2 (patch) | |
tree | 495b545a082c10dc6873d17b3324626aeefdab3a /shell | |
parent | 711ff204f2c1341fb0373ffc1368c22f7b707b80 (diff) | |
download | mongo-c4c2b2559a94d4fe0859c6a25aea5c994b39e6f2.tar.gz |
better Array.tojson option
Diffstat (limited to 'shell')
-rw-r--r-- | shell/utils.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/shell/utils.js b/shell/utils.js index c4c8f40d646..59ab16fd7cd 100644 --- a/shell/utils.js +++ b/shell/utils.js @@ -115,14 +115,18 @@ Date.prototype.tojson = function(){ RegExp.prototype.tojson = RegExp.prototype.toString; -Array.prototype.tojson = function(){ +Array.prototype.tojson = function( sepLines ){ var s = "["; + if ( sepLines ) s += "\n"; for ( var i=0; i<this.length; i++){ - if ( i > 0 ) + if ( i > 0 ){ s += ","; + if ( sepLines ) s += "\n"; + } s += tojson( this[i] ); } s += "]"; + if ( sepLines ) s += "\n"; return s; } |