diff options
Diffstat (limited to 'src/JSON.js')
| -rw-r--r-- | src/JSON.js | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/JSON.js b/src/JSON.js index 0311c317..6fb43f0f 100644 --- a/src/JSON.js +++ b/src/JSON.js @@ -2,7 +2,7 @@ var array = [].constructor; function toJson(obj, pretty){ var buf = []; - toJsonArray(buf, obj, pretty ? "\n " : null, []); + toJsonArray(buf, obj, pretty ? "\n " : _null, []); return buf.join(''); } @@ -31,21 +31,21 @@ function toJsonArray(buf, obj, pretty, stack){ stack.push(obj); } var type = typeof obj; - if (obj === null) { - buf.push("null"); - } else if (type === 'function') { + if (obj === _null) { + buf.push($null); + } else if (type === $function) { return; - } else if (type === 'boolean') { + } else if (type === $boolean) { buf.push('' + obj); - } else if (type === 'number') { + } else if (type === $number) { if (isNaN(obj)) { - buf.push('null'); + buf.push($null); } else { buf.push('' + obj); } - } else if (type === 'string') { + } else if (type === $string) { return buf.push(angular['String']['quoteUnicode'](obj)); - } else if (type === 'object') { + } else if (type === $object) { if (obj instanceof Array) { buf.push("["); var len = obj.length; @@ -53,8 +53,8 @@ function toJsonArray(buf, obj, pretty, stack){ for(var i=0; i<len; i++) { var item = obj[i]; if (sep) buf.push(","); - if (typeof item == 'function' || typeof item == 'undefined') { - buf.push("null"); + if (typeof item == $function || typeof item == $undefined) { + buf.push($null); } else { toJsonArray(buf, item, pretty, stack); } @@ -70,7 +70,7 @@ function toJsonArray(buf, obj, pretty, stack){ var childPretty = pretty ? pretty + " " : false; var keys = []; for(var k in obj) { - if (!obj.hasOwnProperty(k) || k.indexOf('$$') === 0 || obj[k] === undefined) + if (!obj.hasOwnProperty(k) || k.indexOf('$$') === 0 || obj[k] === _undefined) continue; keys.push(k); } @@ -79,7 +79,7 @@ function toJsonArray(buf, obj, pretty, stack){ var key = keys[keyIndex]; try { var value = obj[key]; - if (typeof value != 'function') { + if (typeof value != $function) { if (comma) { buf.push(","); if (pretty) buf.push(pretty); @@ -95,7 +95,7 @@ function toJsonArray(buf, obj, pretty, stack){ buf.push("}"); } } - if (typeof obj == "object") { + if (typeof obj == $object) { stack.pop(); } } |
