Closed Wernfried closed 2 months ago
Please see my proposal to fix the issue:
tojson = function(x, indent, nolint, depth) {
if (x === null)
return "null";
if (x === undefined)
return "undefined";
if (!indent)
indent = "";
if (typeof depth !== 'number') {
depth = 0;
}
switch (typeof x) {
case "string":
return JSON.stringify(x);
case "number":
case "boolean":
return "" + x;
case "object": {
var s = tojsonObject(x, indent, nolint, depth);
if ((nolint == null || nolint == true) && s.length < 80 &&
(indent == null || indent.length == 0)) {
s = s.replace(/[\t\r\n]+/gm, " ");
}
return s;
}
case "function":
if (x === MinKey ) return tojson({ "$minKey" : 1 });
if (x === MaxKey ) return tojson({ "$maxKey" : 1 });
return x.toString();
default:
throw Error("tojson can't handle type " + (typeof x));
}
};
Function
tojson()
does not work for MinKey/MaxKey values:In legacy mongo shell it works fine:
Any idea how to fix it?
Kind Regards Wernfried