var array = [].constructor; function toJson(obj, pretty){ var buf = []; toJsonArray(buf, obj, pretty ? "\n " : _null, []); return buf.join(''); } function fromJson(json) { if (!json) return json; try { var p = parser(json, true); var expression = p.primary(); p.assertAllConsumed(); return expression(); } catch (e) { error("fromJson error: ", json, e); throw e; } } angular['toJson'] = toJson; angular['fromJson'] = fromJson; function toJsonArray(buf, obj, pretty, stack){ if (typeof obj == "object") { if (includes(stack, obj)) { buf.push("RECURSION"); return; } stack.push(obj); } var type = typeof obj; if (obj === _null) { buf.push($null); } else if (type === $function) { return; } else if (type === $boolean) { buf.push('' + obj); } else if (type === $number) { if (isNaN(obj)) { buf.push($null); } else { buf.push('' + obj); } } else if (type === $string) { return buf.push(angular['String']['quoteUnicode'](obj)); } else if (type === $object) { if (obj instanceof Array) { buf.push("["); var len = obj.length; var sep = false; for(var i=0; i