The JSONFormat function is currently found inside jquery-1.7.1.min.js
|
(function(window) { |
|
var p = [], |
|
push = function( m ) { return '\\' + p.push( m ) + '\\'; }; |
|
pop = function( m, i ) { return p[i-1] }; |
|
tabs = function( count ) { return new Array( count + 1 ).join( '\t' ); }; |
|
|
|
window.JSONFormat = function( json ) { |
|
p = []; |
|
var out = "", |
|
indent = 0; |
|
|
|
// Extract backslashes and strings |
|
json = json |
|
.replace( /\\./g, push ) |
|
.replace( /(".*?"|'.*?')/g, push ) |
|
.replace( /\s+/, '' ); |
|
|
|
// Indent and insert newlines |
|
for( var i = 0; i < json.length; i++ ) { |
|
var c = json.charAt(i); |
|
|
|
switch(c) { |
|
case '{': |
|
case '[': |
|
out += c + "\n" + tabs(++indent); |
|
break; |
|
case '}': |
|
case ']': |
|
out += "\n" + tabs(--indent) + c; |
|
break; |
|
case ',': |
|
out += ",\n" + tabs(indent); |
|
break; |
|
case ':': |
|
out += ": "; |
|
break; |
|
default: |
|
out += c; |
|
break; |
|
} |
|
} |
|
|
|
// Strip whitespace from numeric arrays and put backslashes |
|
// and strings back in |
|
out = out |
|
.replace( /\[[\d,\s]+?\]/g, function(m){ return m.replace(/\s/g,''); } ) |
|
.replace( /\\(\d+)\\/g, pop ); |
|
|
|
return out; |
|
}; |
|
})(window); |
However, it does not seem to be related to jQuery in any way, and should probably be in its own file called json-format.js
The
JSONFormatfunction is currently found inside jquery-1.7.1.min.jsImpact/lib/weltmeister/jquery-1.7.1.min.js
Lines 105 to 155 in ca59f0e
However, it does not seem to be related to jQuery in any way, and should probably be in its own file called json-format.js