mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
better Array.tojson option
This commit is contained in:
parent
711ff204f2
commit
c4c2b2559a
@ -115,14 +115,18 @@ Date.prototype.tojson = function(){
|
|||||||
|
|
||||||
RegExp.prototype.tojson = RegExp.prototype.toString;
|
RegExp.prototype.tojson = RegExp.prototype.toString;
|
||||||
|
|
||||||
Array.prototype.tojson = function(){
|
Array.prototype.tojson = function( sepLines ){
|
||||||
var s = "[";
|
var s = "[";
|
||||||
|
if ( sepLines ) s += "\n";
|
||||||
for ( var i=0; i<this.length; i++){
|
for ( var i=0; i<this.length; i++){
|
||||||
if ( i > 0 )
|
if ( i > 0 ){
|
||||||
s += ",";
|
s += ",";
|
||||||
|
if ( sepLines ) s += "\n";
|
||||||
|
}
|
||||||
s += tojson( this[i] );
|
s += tojson( this[i] );
|
||||||
}
|
}
|
||||||
s += "]";
|
s += "]";
|
||||||
|
if ( sepLines ) s += "\n";
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user