Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/units/helpers/json_helper.php
Show All 19 Lines | |||||
// var $replace = Array ('\\\\', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'); | // var $replace = Array ('\\\\', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'); | ||||
// \x{2028} is some strange char found in GTA responses... it breaks javascript | // \x{2028} is some strange char found in GTA responses... it breaks javascript | ||||
var $match = Array ('/\\\\/u', '/\\"/u', '/\\t/u', '/\\n/u', '/\\r/u', '/\\x{2028}/u'); | var $match = Array ('/\\\\/u', '/\\"/u', '/\\t/u', '/\\n/u', '/\\r/u', '/\\x{2028}/u'); | ||||
var $replace = Array ('\\\\\\\\', '\\"', '\\t', '\\n', '\\r', ''); | var $replace = Array ('\\\\\\\\', '\\"', '\\t', '\\n', '\\r', ''); | ||||
/** | /** | ||||
* Object constructor | * Object constructor | ||||
* | |||||
* @return JSONHelper | |||||
*/ | */ | ||||
function JSONHelper() { | public function __construct() | ||||
{ | |||||
} | } | ||||
/** | /** | ||||
* Parse structure to JSON | * Parse structure to JSON | ||||
* | * | ||||
* @param mixed $data | * @param mixed $data | ||||
* @return string | * @return string | ||||
Show All 30 Lines | |||||
} | } | ||||
elseif ( is_bool($data) ) { | elseif ( is_bool($data) ) { | ||||
$data = $data ? 'true' : 'false'; | $data = $data ? 'true' : 'false'; | ||||
} | } | ||||
else { | else { | ||||
$data = 'null'; | $data = 'null'; | ||||
} | } | ||||
} | } | ||||
return $data; | return $data; | ||||
} | } | ||||
/** | /** | ||||
* Enter description here... | * Enter description here... | ||||
* | * | ||||
* @param Array $data | * @param Array $data | ||||
* @param string $type | * @param string $type | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | |||||
return $string; | return $string; | ||||
// Escape certain ASCII characters: | // Escape certain ASCII characters: | ||||
// 0x08 => \b | // 0x08 => \b | ||||
// 0x0c => \f | // 0x0c => \f | ||||
// return str_replace(array(chr(0x08), chr(0x0C)), array('\b', '\f'), $string); | // return str_replace(array(chr(0x08), chr(0x0C)), array('\b', '\f'), $string); | ||||
} | } | ||||
} | } | ||||
No newline at end of file |