-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson.min.js
8 lines (8 loc) · 2.82 KB
/
json.min.js
1
2
3
4
5
6
7
8
// 2023.05.10 json2.js https://github.com/douglascrockford/JSON-js
"object"!==typeof JSON&&(JSON={});
(function(){function l(a){return 10>a?"0"+a:a}function p(){return this.valueOf()}function q(a){r.lastIndex=0;return r.test(a)?'"'+a.replace(r,function(c){var d=v[c];return"string"===typeof d?d:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function m(a,c){var d=f,b=c[a];b&&"object"===typeof b&&"function"===typeof b.toJSON&&(b=b.toJSON(a));"function"===typeof k&&(b=k.call(c,a,b));switch(typeof b){case "string":return q(b);case "number":return isFinite(b)?String(b):"null";case "boolean":case "null":return String(b);
case "object":if(!b)return"null";f+=n;var g=[];if("[object Array]"===Object.prototype.toString.apply(b)){var h=b.length;for(a=0;a<h;a+=1)g[a]=m(a,b)||"null";c=0===g.length?"[]":f?"[\n"+f+g.join(",\n"+f)+"\n"+d+"]":"["+g.join(",")+"]";f=d;return c}if(k&&"object"===typeof k)for(h=k.length,a=0;a<h;a+=1){if("string"===typeof k[a]){var e=k[a];(c=m(e,b))&&g.push(q(e)+(f?": ":":")+c)}}else for(e in b)Object.prototype.hasOwnProperty.call(b,e)&&(c=m(e,b))&&g.push(q(e)+(f?": ":":")+c);c=0===g.length?"{}":f?
"{\n"+f+g.join(",\n"+f)+"\n"+d+"}":"{"+g.join(",")+"}";f=d;return c}}var w=/^[\],:{}\s]*$/,x=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,y=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,z=/(?:^|:|,)(?:\s*\[)+/g,r=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,t=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;"function"!==typeof Date.prototype.toJSON&&
(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+l(this.getUTCMonth()+1)+"-"+l(this.getUTCDate())+"T"+l(this.getUTCHours())+":"+l(this.getUTCMinutes())+":"+l(this.getUTCSeconds())+"Z":null},Boolean.prototype.toJSON=p,Number.prototype.toJSON=p,String.prototype.toJSON=p);var f,n,k;if("function"!==typeof JSON.stringify){var v={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};JSON.stringify=function(a,c,d){var b;n=f="";if("number"===
typeof d)for(b=0;b<d;b+=1)n+=" ";else"string"===typeof d&&(n=d);if((k=c)&&"function"!==typeof c&&("object"!==typeof c||"number"!==typeof c.length))throw Error("JSON.stringify");return m("",{"":a})}}"function"!==typeof JSON.parse&&(JSON.parse=function(a,c){function d(b,g){var h,e=b[g];if(e&&"object"===typeof e)for(h in e)if(Object.prototype.hasOwnProperty.call(e,h)){var u=d(e,h);void 0!==u?e[h]=u:delete e[h]}return c.call(b,g,e)}a=String(a);t.lastIndex=0;t.test(a)&&(a=a.replace(t,function(b){return"\\u"+
("0000"+b.charCodeAt(0).toString(16)).slice(-4)}));if(w.test(a.replace(x,"@").replace(y,"]").replace(z,"")))return a=eval("("+a+")"),"function"===typeof c?d({"":a},""):a;throw new SyntaxError("JSON.parse");})})();