This repository has been archived by the owner on May 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
/
json3.min.js
18 lines (18 loc) · 8.39 KB
/
json3.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*! JSON v3.3.2 | https://bestiejs.github.io/json3 | Copyright 2012-2015, Kit Cambridge, Benjamin Tan | http://kit.mit-license.org */
(function(){function N(v,q){function n(a,k){try{a()}catch(b){k&&k()}}function l(a){if(null!=l[a])return l[a];var k;if("bug-string-char-index"==a)k="a"!="a"[0];else if("json"==a)k=l("json-stringify")&&l("date-serialization")&&l("json-parse");else if("date-serialization"==a){if(k=l("json-stringify")&&w){var b=q.stringify;n(function(){k='"-271821-04-20T00:00:00.000Z"'==b(new A(-864E13))&&'"+275760-09-13T00:00:00.000Z"'==b(new A(864E13))&&'"-000001-01-01T00:00:00.000Z"'==b(new A(-621987552E5))&&'"1969-12-31T23:59:59.999Z"'==
b(new A(-1))})}}else{var f;if("json-stringify"==a){var b=q.stringify,e="function"==typeof b;e&&((f=function(){return 1}).toJSON=f,n(function(){e="0"===b(0)&&"0"===b(new C)&&'""'==b(new B)&&b(t)===u&&b(u)===u&&b()===u&&"1"===b(f)&&"[1]"==b([f])&&"[null]"==b([u])&&"null"==b(null)&&"[null,null,null]"==b([u,t,null])&&'{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'==b({a:[f,!0,!1,null,"\x00\b\n\f\r\t"]})&&"1"===b(null,f)&&"[\n 1,\n 2\n]"==b([1,2],null,1)},function(){e=!1}));k=e}if("json-parse"==a){var c=
q.parse,d;"function"==typeof c&&n(function(){0===c("0")&&!c(!1)&&(f=c('{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}'),d=5==f.a.length&&1===f.a[0])&&(n(function(){d=!c('"\t"')}),d&&n(function(){d=1!==c("01")}),d&&n(function(){d=1!==c("1.")}))},function(){d=!1});k=d}}return l[a]=!!k}v||(v=g.Object());q||(q=g.Object());var C=v.Number||g.Number,B=v.String||g.String,G=v.Object||g.Object,A=v.Date||g.Date,J=v.SyntaxError||g.SyntaxError,K=v.TypeError||g.TypeError,L=v.Math||g.Math,H=v.JSON||g.JSON;"object"==
typeof H&&H&&(q.stringify=H.stringify,q.parse=H.parse);var G=G.prototype,t=G.toString,u,w=new A(-0xc782b5b800cec);n(function(){w=-109252==w.getUTCFullYear()&&0===w.getUTCMonth()&&1===w.getUTCDate()&&10==w.getUTCHours()&&37==w.getUTCMinutes()&&6==w.getUTCSeconds()&&708==w.getUTCMilliseconds()});l["bug-string-char-index"]=l["date-serialization"]=l.json=l["json-stringify"]=l["json-parse"]=null;if(!l("json")){var D=l("bug-string-char-index"),r;(r=G.hasOwnProperty)||(r=function(a){var k={},b;(k.__proto__=
null,k.__proto__={toString:1},k).toString!=t?r=function(b){var a=this.__proto__;b=b in(this.__proto__=null,this);this.__proto__=a;return b}:(b=k.constructor,r=function(a){var k=(this.constructor||b).prototype;return a in this&&!(a in k&&this[a]===k[a])});k=null;return r.call(this,a)});var E=function(a,k){var b=0,c,e,p;(c=function(){this.valueOf=0}).prototype.valueOf=0;e=new c;for(p in e)r.call(e,p)&&b++;c=e=null;b?E=2==b?function(b,a){var k={},c="[object Function]"==t.call(b),e;for(e in b)c&&"prototype"==
e||r.call(k,e)||!(k[e]=1)||!r.call(b,e)||a(e)}:function(b,a){var k="[object Function]"==t.call(b),c,e;for(c in b)k&&"prototype"==c||!r.call(b,c)||(e="constructor"===c)||a(c);(e||r.call(b,c="constructor"))&&a(c)}:(e="valueOf toString toLocaleString propertyIsEnumerable isPrototypeOf hasOwnProperty constructor".split(" "),E=function(b,a){var k="[object Function]"==t.call(b),c,f=!k&&"function"!=typeof b.constructor&&F[typeof b.hasOwnProperty]&&b.hasOwnProperty||r;for(c in b)k&&"prototype"==c||!f.call(b,
c)||a(c);for(k=e.length;c=e[--k];f.call(b,c)&&a(c));});return E(a,k)};if(!l("json-stringify")||!l(" date-serialization")){var M={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},y=function(a,c){return("000000"+(c||0)).slice(-a)},R=function(a){for(var c='"',b=0,f=a.length,e=!D||10<f,p=e&&(D?a.split(""):a);b<f;b++){var d=a.charCodeAt(b);switch(d){case 8:case 9:case 10:case 12:case 13:case 34:case 92:c+=M[d];break;default:if(32>d){c+="\\u00"+y(2,d.toString(16));break}c+=e?p[b]:a.charAt(b)}}return c+
'"'},O=function(a){var c,b,f,e,p,d,h,g,m;if(w)c=function(a){b=a.getUTCFullYear();f=a.getUTCMonth();e=a.getUTCDate();d=a.getUTCHours();h=a.getUTCMinutes();g=a.getUTCSeconds();m=a.getUTCMilliseconds()};else{var x=L.floor,l=[0,31,59,90,120,151,181,212,243,273,304,334],n=function(b,a){return l[a]+365*(b-1970)+x((b-1969+(a=+(1<a)))/4)-x((b-1901+a)/100)+x((b-1601+a)/400)};c=function(a){e=x(a/864E5);for(b=x(e/365.2425)+1970-1;n(b+1,0)<=e;b++);for(f=x((e-n(b,0))/30.42);n(b,f+1)<=e;f++);e=1+e-n(b,f);p=(a%
864E5+864E5)%864E5;d=x(p/36E5)%24;h=x(p/6E4)%60;g=x(p/1E3)%60;m=p%1E3}}O=function(a){a>-1/0&&a<1/0?(c(a),a=(0>=b||1E4<=b?(0>b?"-":"+")+y(6,0>b?-b:b):y(4,b))+"-"+y(2,f+1)+"-"+y(2,e)+"T"+y(2,d)+":"+y(2,h)+":"+y(2,g)+"."+y(3,m)+"Z",b=f=e=d=h=g=m=null):a=null;return a};return O(a)},P=function(a,c,b,f,e,p,d){var h,g,m,l,q,r;n(function(){h=c[a]});"object"==typeof h&&h&&(h.getUTCFullYear&&"[object Date]"==t.call(h)&&h.toJSON===A.prototype.toJSON?h=O(h):"function"==typeof h.toJSON&&(h=h.toJSON(a)));b&&(h=
b.call(c,a,h));if(h==u)return h===u?h:"null";g=typeof h;"object"==g&&(m=t.call(h));switch(m||g){case "boolean":case "[object Boolean]":return""+h;case "number":case "[object Number]":return h>-1/0&&h<1/0?""+h:"null";case "string":case "[object String]":return R(""+h)}if("object"==typeof h){for(g=d.length;g--;)if(d[g]===h)throw K();d.push(h);l=[];r=p;p+=e;if("[object Array]"==m){q=0;for(g=h.length;q<g;q++)m=P(q,h,b,f,e,p,d),l.push(m===u?"null":m);g=l.length?e?"[\n"+p+l.join(",\n"+p)+"\n"+r+"]":"["+
l.join(",")+"]":"[]"}else E(f||h,function(a){var c=P(a,h,b,f,e,p,d);c!==u&&l.push(R(a)+":"+(e?" ":"")+c)}),g=l.length?e?"{\n"+p+l.join(",\n"+p)+"\n"+r+"}":"{"+l.join(",")+"}":"{}";d.pop();return g}};q.stringify=function(a,c,b){var f,e,g,d;if(F[typeof c]&&c)if(d=t.call(c),"[object Function]"==d)e=c;else if("[object Array]"==d){g={};for(var h=0,m=c.length,l;h<m;l=c[h++],(d=t.call(l),"[object String]"==d||"[object Number]"==d)&&(g[l]=1));}if(b)if(d=t.call(b),"[object Number]"==d){if(0<(b-=b%1))for(f=
"",10<b&&(b=10);f.length<b;f+=" ");}else"[object String]"==d&&(f=10>=b.length?b:b.slice(0,10));return P("",(l={},l[""]=a,l),e,g,f,"",[])}}if(!l("json-parse")){var U=B.fromCharCode,V={92:"\\",34:'"',47:"/",98:"\b",116:"\t",110:"\n",102:"\f",114:"\r"},c,I,m=function(){c=I=null;throw J();},z=function(){for(var a=I,k=a.length,b,f,e,g,d;c<k;)switch(d=a.charCodeAt(c),d){case 9:case 10:case 13:case 32:c++;break;case 123:case 125:case 91:case 93:case 58:case 44:return b=D?a.charAt(c):a[c],c++,b;case 34:b=
"@";for(c++;c<k;)if(d=a.charCodeAt(c),32>d)m();else if(92==d)switch(d=a.charCodeAt(++c),d){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:b+=V[d];c++;break;case 117:f=++c;for(e=c+4;c<e;c++)d=a.charCodeAt(c),48<=d&&57>=d||97<=d&&102>=d||65<=d&&70>=d||m();b+=U("0x"+a.slice(f,c));break;default:m()}else{if(34==d)break;d=a.charCodeAt(c);for(f=c;32<=d&&92!=d&&34!=d;)d=a.charCodeAt(++c);b+=a.slice(f,c)}if(34==a.charCodeAt(c))return c++,b;m();default:f=c;45==d&&(g=!0,d=a.charCodeAt(++c));
if(48<=d&&57>=d){for(48==d&&(d=a.charCodeAt(c+1),48<=d&&57>=d)&&m();c<k&&(d=a.charCodeAt(c),48<=d&&57>=d);c++);if(46==a.charCodeAt(c)){for(e=++c;e<k&&(d=a.charCodeAt(e),48<=d&&57>=d);e++);e==c&&m();c=e}d=a.charCodeAt(c);if(101==d||69==d){d=a.charCodeAt(++c);43!=d&&45!=d||c++;for(e=c;e<k&&(d=a.charCodeAt(e),48<=d&&57>=d);e++);e==c&&m();c=e}return+a.slice(f,c)}g&&m();b=a.slice(c,c+4);if("true"==b)return c+=4,!0;if("fals"==b&&101==a.charCodeAt(c+4))return c+=5,!1;if("null"==b)return c+=4,null;m()}return"$"},
Q=function(a){var c,b;"$"==a&&m();if("string"==typeof a){if("@"==(D?a.charAt(0):a[0]))return a.slice(1);if("["==a){for(c=[];;){a=z();if("]"==a)break;b?","==a?(a=z(),"]"==a&&m()):m():b=!0;","==a&&m();c.push(Q(a))}return c}if("{"==a){for(c={};;){a=z();if("}"==a)break;b?","==a?(a=z(),"}"==a&&m()):m():b=!0;","!=a&&"string"==typeof a&&"@"==(D?a.charAt(0):a[0])&&":"==z()||m();c[a.slice(1)]=Q(z())}return c}m()}return a},T=function(a,c,b){b=S(a,c,b);b===u?delete a[c]:a[c]=b},S=function(a,c,b){var f=a[c],
e;if("object"==typeof f&&f)if("[object Array]"==t.call(f))for(e=f.length;e--;T(f,e,b));else E(f,function(a){T(f,a,b)});return b.call(a,c,f)};q.parse=function(a,g){var b,f;c=0;I=""+a;b=Q(z());"$"!=z()&&m();c=I=null;return g&&"[object Function]"==t.call(g)?S((f={},f[""]=b,f),"",g):b}}}q.runInContext=N;return q}var J=typeof define==="function"&&define.amd,F={"function":!0,object:!0},B=F[typeof exports]&&exports&&!exports.nodeType&&exports,g=F[typeof window]&&window||this,n=B&&F[typeof module]&&module&&
!module.nodeType&&"object"==typeof global&&global;!n||n.global!==n&&n.window!==n&&n.self!==n||(g=n);if(B&&!J)N(g,B);else{var K=g.JSON,L=g.JSON3,M=!1,C=N(g,g.JSON3={noConflict:function(){M||(M=!0,g.JSON=K,g.JSON3=L,K=L=null);return C}});g.JSON={parse:C.parse,stringify:C.stringify}}J&&define(function(){return C})}).call(this);