function json_decode2($json)

{

$comment = false;

$out = '$x=';

 

for ($i=0; $i<strlen($json); $i++)

{

if (!$comment)

{

if (($json[$i] == '{') || ($json[$i] == '[')) $out .= ' array(';

else if (($json[$i] == '}') || ($json[$i] == ']')) $out .= ')';

else if ($json[$i] == ':') $out .= '=>';

else $out .= $json[$i];

}

else $out .= $json[$i];

 

if ($json[$i] == '"' && $json[($i-1)]!="\\") $comment = !$comment;

}

    

    eval($out . ';');

return $x;

}

不过这个返回的是Array

要返回object 则要用到 service_json类了

posted on 2014-05-17 11:16  今夜太冷  阅读(735)  评论(0编辑  收藏  举报