summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorStefano J. Attardi <stefano@attardi.org>2011-02-28 16:50:20 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2013-03-20 06:02:47 -0500
commit1520108252b180439092bd8889a6e38e9c7c9100 (patch)
treec003c88855f2ff27f23e06cf96828adafaea247f /share
parent574555be3b0ee2fe07d4b7c5b49af3227d15acdc (diff)
downloadcouchdb-1520108252b180439092bd8889a6e38e9c7c9100.tar.gz
Use native JSON everywhere. Also, no eval for parsing JSON, thanks.
Conflicts: couchjs/js/SConscript share/server/json2.js share/server/render.js share/server/util.js
Diffstat (limited to 'share')
-rw-r--r--share/server/loop.js2
-rw-r--r--share/server/util.js9
-rw-r--r--share/server/views.js2
3 files changed, 5 insertions, 8 deletions
diff --git a/share/server/loop.js b/share/server/loop.js
index fcd016f17..4f8d106b7 100644
--- a/share/server/loop.js
+++ b/share/server/loop.js
@@ -20,7 +20,7 @@ function init_sandbox() {
sandbox.emit = Views.emit;
sandbox.sum = Views.sum;
sandbox.log = log;
- sandbox.toJSON = Couch.toJSON;
+ sandbox.toJSON = JSON.stringify;
sandbox.JSON = JSON;
sandbox.provides = Mime.provides;
sandbox.registerType = Mime.registerType;
diff --git a/share/server/util.js b/share/server/util.js
index b7a62d810..37b75c226 100644
--- a/share/server/util.js
+++ b/share/server/util.js
@@ -58,9 +58,6 @@ var resolveModule = function(names, mod, root) {
var Couch = {
// moving this away from global so we can move to json2.js later
- toJSON : function (val) {
- return JSON.stringify(val);
- },
compileFunction : function(source, ddoc, name) {
if (!source) throw(["error","not_found","missing function"]);
@@ -132,10 +129,10 @@ var Couch = {
}
};
-// prints the object as JSON, and rescues and logs any toJSON() related errors
+// prints the object as JSON, and rescues and logs any JSON.stringify() related errors
function respond(obj) {
try {
- print(Couch.toJSON(obj));
+ print(JSON.stringify(obj));
} catch(e) {
log("Error converting object to JSON: " + e.toString());
log("error on obj: "+ obj.toSource());
@@ -147,7 +144,7 @@ function log(message) {
if (typeof message == "xml") {
message = message.toXMLString();
} else if (typeof message != "string") {
- message = Couch.toJSON(message);
+ message = JSON.stringify(message);
}
respond(["log", String(message)]);
};
diff --git a/share/server/views.js b/share/server/views.js
index 646aac80d..7c53e19bd 100644
--- a/share/server/views.js
+++ b/share/server/views.js
@@ -30,7 +30,7 @@ var Views = (function() {
reductions[i] = null;
}
};
- var reduce_line = Couch.toJSON(reductions);
+ var reduce_line = JSON.stringify(reductions);
var reduce_length = reduce_line.length;
// TODO make reduce_limit config into a number
if (State.query_config && State.query_config.reduce_limit &&