mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
issue 2740 add unique visitor statistics api
json_encode2 function modify (Because Maserati only supports php5.2.4 above) git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12374 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
56110ce3c3
commit
c7fb2d5ae8
4 changed files with 12 additions and 36 deletions
|
|
@ -1109,39 +1109,7 @@ function detectUTF8($string, $return_convert = false, $urldecode = true)
|
|||
*/
|
||||
function json_encode2($data)
|
||||
{
|
||||
switch (gettype($data))
|
||||
{
|
||||
case 'boolean':
|
||||
return $data?'true':'false';
|
||||
case 'integer':
|
||||
case 'double':
|
||||
return $data;
|
||||
case 'string':
|
||||
return '"'.strtr($data, array('\\'=>'\\\\','"'=>'\\"')).'"';
|
||||
case 'object':
|
||||
$data = get_object_vars($data);
|
||||
case 'array':
|
||||
$rel = false; // relative array?
|
||||
$key = array_keys($data);
|
||||
foreach($key as $v)
|
||||
{
|
||||
if(!is_int($v))
|
||||
{
|
||||
$rel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$arr = array();
|
||||
foreach ($data as $k=>$v)
|
||||
{
|
||||
$arr[] = ($rel?'"'.strtr($k, array('\\'=>'\\\\','"'=>'\\"')).'":':'').json_encode2($v);
|
||||
}
|
||||
|
||||
return $rel?'{'.join(',', $arr).'}':'['.join(',', $arr).']';
|
||||
default:
|
||||
return '""';
|
||||
}
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue