1.eval方法
function strToJson(str){
var json = eval('(' + str + ')');
return json;
} 2.new Function方法
function strToJson(str){
var json = (new Function("return " + str))();
return json;
... 1.eval方法
function strToJson(str){
var json = eval('(' + str + ')');
return json;
} 2.new Function方法
function strToJson(str){
var json = (new Function("return " + str))();
return json;
... xml转array
字串
$xml = simplexml_load_string($data);
$array = json_decode(json_encode($xml),TRUE);
文件
$xml = simplexml_load_file($data);
$array= json_decode(json_encode($xml),TRUE);
或者
$array = (array) sim...
if ( !function_exists('json_decode') ){
function json_decode($json)
{
$comment = false;
$out = '$x=';
for ($i=0; $i<strlen($json); $i++)
{
if (!$comment)
...