3 lines
17 KiB
JavaScript
3 lines
17 KiB
JavaScript
|
|
/* Copyright (c) 2013-2015 Richard Rodger, MIT License, https://github.com/rjrodger/jsonic */
|
||
|
|
"use strict";(function(){function t(r,e,n){if(n++,null==r)return"null";var i=Object.prototype.toString.call(r).charAt(8);if("F"===i&&!e.showfunc)return null;if(e.custom){if(r.hasOwnProperty("toString"))return r.toString();if(r.hasOwnProperty("inspect"))return r.inspect()}var u,o,c,a=0;if("N"===i)return isNaN(r)?"null":r.toString();if("O"===i){if(u=[],n<=e.depth){o=0;for(a in r){if(o>=e.maxitems)break;o++;var s=!0;for(c=0;c<e.exclude.length&&s;c++)s=!~a.indexOf(e.exclude[c]);s=s&&!e.omit[a];var l=t(r[a],e,n);if(null!=l&&s){var f=a.match(/^[a-zA-Z0-9_$]+$/)?a:JSON.stringify(a);u.push(f+":"+l)}}}return"{"+u.join(",")+"}"}if("A"===i){if(u=[],n<=e.depth)for(;a<r.length&&a<e.maxitems;a++){var l=t(r[a],e,n);null!=l&&u.push(l)}return"["+u.join(",")+"]"}var p=r.toString();return(~" \"'\r\n ,}]".indexOf(p[0])||!~p.match(/,}]/)||~" \r\n ".indexOf(p[p.length-1]))&&(p="'"+p.replace(/'/g,"\\'")+"'"),p}var r=this,e=r.jsonic,n=r.jsonic=function(t){return"[object String]"!==Object.prototype.toString.call(t)?Object.prototype.toString.call(t).match(/\[object (Object|Array)\]/)?t:""+t:(t=t.trim(),"{"!=t[0]&&"["!=t[0]&&(t="{"+t+"}"),i.parse(t))};n.noConflict=function(){return r.jsonic=e,n};var i=function(){function t(t,r){function e(){this.constructor=t}e.prototype=r.prototype,t.prototype=new e}function r(t,r,e,n,i,u){this.message=t,this.expected=r,this.found=e,this.offset=n,this.line=i,this.column=u,this.name="SyntaxError"}function e(t){function e(r){function e(r,e,n){var i,u;for(i=e;n>i;i++)u=t.charAt(i),"\n"===u?(r.seenCR||r.line++,r.column=1,r.seenCR=!1):"\r"===u||"\u2028"===u||"\u2029"===u?(r.line++,r.column=1,r.seenCR=!0):(r.column++,r.seenCR=!1)}return Ge!==r&&(Ge>r&&(Ge=0,He={line:1,column:1,seenCR:!1}),e(He,Ge,r),Ge=r),He}function n(t){Ke>Ue||(Ue>Ke&&(Ke=Ue,Le=[]),Le.push(t))}function i(n,i,u){function o(t){var r=1;for(t.sort(function(t,r){return t.description<r.description?-1:t.description>r.description?1:0});r<t.length;)t[r-1]===t[r]?t.splice(r,1):r++}function c(t,r){function e(t){function r(t){return t.charCodeAt(0).toString(16).toUpperCase()}return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(t){return"\\x0"+r(t)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(t){return"\\x"+r(t)}).replace(/[\u0180-\u0FFF]/g,function(t){return"\\u0"+r(t)}).replace(/[\u1080-\uFFFF]/g,function(t){return"\\u"+r(t)})}var n,i,u,o=new Array(t.length);for(u=0;u<t.length;u++)o[u]=t[u].description;return n=t.length>1?o.slice(0,-1).join(", ")+" or "+o[t.length-1]:o[0],i=r?'"'+e(r)+'"':"end of input","Expected "+n+" but "+i+" found."}var a=e(u),s=u<t.length?t.charAt(u):null;return null!==i&&o(i),new r(null!==n?n:c(i,s),i,s,u,a.line,a.column)}function u(){var t,r,e;return t=Ue,r=$(),r!==k?(e=o(),e!==k?(De=t,r=B(e),t=r):(Ue=t,t=P)):(Ue=t,t=P),t===k&&(t=Ue,r=$(),r!==k?(e=s(),e!==k?(De=t,r=I(e),t=r):(Ue=t,t=P)):(Ue=t,t=P)),t}function o(){var r,e,i,u,o,a;return r=Ue,123===t.charCodeAt(Ue)?(e=U,Ue++):(e=k,0===Me&&n(D)),e!==k?(i=$(),i!==k?(125===t.charCodeAt(Ue)?(u=G,Ue++):(u=k,0===Me&&n(H)),u!==k?(o=$(),o!==k?(De=r,e=K(),r=e):(Ue=r,r=P)):(Ue=r,r=P)):(Ue=r,r=P)):(Ue=r,r=P),r===k&&(r=Ue,123===t.charCodeAt(Ue)?(e=U,Ue++):(e=k,0===Me&&n(D)),e!==k?(i=$(),i!==k?(u=c(),u!==k?(125===t.charCodeAt(Ue)?(o=G,Ue++):(o=k,0===Me&&n(H)),o!==k?(a=$(),a!==k?(De=r,e=L(u),r=e):(Ue=r,r=P)):(Ue=r,r=P)):(Ue=r,r=P)):(Ue=r,r=P)):(Ue=r,r=P)),r}function c(){var r,e,i,u,o,c,s,l;if(r=Ue,44===t.charCodeAt(Ue)?(e=Q,Ue++):(e=k,0===Me&&n(T)),e===k&&(e=M),e!==k)if(i=a(),i===k&&(i=M),i!==k){for(u=[],o=Ue,44===t.charCodeAt(Ue)?(c=Q,Ue++):(c=k,0===Me&&n(T)),c!==k?(s=$(),s!==k?(l=a(),l!==k?(c=[c,s,l],o=c):(Ue=o,o=P)):(Ue=o,o=P)):(Ue=o,o=P);o!==k;)u.push(o),o=Ue,44===t.charCodeAt(Ue)?(c=Q,Ue++):(c=k,0===Me&&n(T)),c!==k?(s=$(),s!==k?(l=a(),l!==k?(c=[c,s,l],o=c):(Ue=o,o=P)):(Ue=o,o=P)):(Ue=o,o=P);u!==k?(44===t.charCodeAt(Ue)?(o=Q,Ue++):(o=k,0===Me&&n(T)),o===k&&(o=M),o!==k?(c=$(),c!==k?(De=r,e=V(i,u),r=e):(Ue=r,r=P)):(Ue=r,r=P)):(Ue=r,r=P)}else Ue=r,r=P;else
|
||
|
|
//# sourceMappingURL=jsonic-min.map
|