/*
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 3.0.0b1
build: 1163
*/
YUI.add("json-parse",function(Y){var Native=Y.config.win.JSON,_UNICODE_EXCEPTIONS=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,_ESCAPES=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,_VALUES=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,_BRACKETS=/(?:^|:|,)(?:\s*\[)+/g,_INVALID=/[^\],:{}\s]/,_SIMPLE=/^\s*(?:"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)\s*$/,_escapeException=function(c){return"\\u"+("0000"+(+(c.charCodeAt(0))).toString(16)).slice(-4);},_revive=function(data,reviver){var walk=function(o,key){var k,v,value=o[key];if(value&&typeof value==="object"){for(k in value){if(value.hasOwnProperty(k)){v=walk(value,k);if(v===undefined){delete value[k];}else{value[k]=v;}}}}return reviver.call(o,key,value);};return typeof reviver==="function"?walk({"":data},""):data;},_parse=function(s,reviver){if(typeof s==="string"){s=s.replace(_UNICODE_EXCEPTIONS,_escapeException);if(!_INVALID.test(s.replace(_ESCAPES,"@").replace(_VALUES,"]").replace(_BRACKETS,""))){return _revive(eval("("+s+")"),reviver);}}throw new SyntaxError("JSON.parse");},test;if(Native&&Object.prototype.toString.call(Native)==="[object JSON]"){try{test=Native.parse('{"x":1}',function(k,v){return k=="x"?2:v;});switch(test.x){case 1:_parse=function(s,reviver){return _SIMPLE.test(s)?eval("("+s+")"):_revive(Native.parse(s),reviver);};break;case 2:_parse=function(s,reviver){return Native.parse(s,reviver);};break;}}catch(e){}}Y.mix(Y.namespace("JSON"),{parse:_parse});},"3.0.0b1");YUI.add("json-stringify",function(C){var V=Object.prototype.toString,F=C.Lang,A=F.isFunction,M=F.isArray,D=F.type,Q="string",S="number",P="boolean",N="object",W="array",O="regexp",I="error",U="null",E="date",a="",Z="{",H="}",G="[",T="]",R=",",K=",\n",B="\n",J=":",X=": ",L='"';C.mix(C.namespace("JSON"),{_SPECIAL_CHARS:/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,_CHARS:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},dateToString:function(b){function Y(c){return c<10?"0"+c:c;}return L+b.getUTCFullYear()+"-"+Y(b.getUTCMonth()+1)+"-"+Y(b.getUTCDate())+"T"+Y(b.getUTCHours())+J+Y(b.getUTCMinutes())+J+Y(b.getUTCSeconds())+"Z"+L;},stringify:function(c,n,d){var e=C.JSON._CHARS,Y=C.JSON._SPECIAL_CHARS,i=A(n)?n:null,b=[],q=C.JSON.dateToString,l=V.call(d).match(/String|Number/);if(i||typeof n!=="object"){n=undefined;}if(l){if(l[0]==="Number"){d=new Array(Math.min(Math.max(0,d),100)+1).join(" ");}l=d;}function k(m){if(!e[m]){e[m]="\\u"+("0000"+(+(m.charCodeAt(0))).toString(16)).slice(-4);}return e[m];}function p(m){return L+m.replace(Y,k)+L;}function g(r){for(var m=b.length-1;m>=0;--m){if(b[m]===r){throw new Error("JSON.stringify. Cyclical reference");}}return false;}function f(m){return m.replace(/^/gm,d);}function j(m,u){b.push(m);var y=[],w=l?X:J,t,s,x,r,z;if(u){for(t=m.length-1;t>=0;--t){y[t]=h(m,t)||U;}}else{r=M(n)?n:C.Object.keys(m);for(t=0,s=0,x=r.length;t<x;++t){if(typeof r[t]===Q){z=h(m,r[t]);if(z){y[s++]=p(r[t])+w+z;}}}}b.pop();if(l&&y.length){return u?G+B+f(y.join(K))+B+T:Z+B+f(y.join(K))+B+H;}else{return u?G+y.join(R)+T:Z+y.join(R)+H;}}function h(s,r){var u=A(i)?i.call(s,r,s[r]):s[r],m=D(u);if(m===N){if(/String|Number|Boolean/.test(V.call(u))){u=u.valueOf();m=D(u);}}switch(m){case Q:return p(u);case S:return isFinite(u)?u+a:U;case P:return u+a;case E:return q(u);case U:return U;case W:g(u);return j(u,true);case O:case I:case N:g(u);return j(u);default:return undefined;}}return h({"":c},a);}});},"3.0.0b1");YUI.add("json",function(A){},"3.0.0b1",{use:["json-parse","json-stringify"]});