噜噜哒
我的作法是使用替代对字符串进行规范化,也就是给他们都加上双引号,变成规范的php JSON 格式,然后再做处理。具体如下:<?php
$data='{
655199:{
480:[780,2,980],
397:[770,2,990],
596:[770,2,990]
},
655201:{
481:[780,2,980],
398:[770,2,990],
599:[770,2,990]
}
}';$data = preg_replace('/(\d+)/','"$1"',$data);var_dump(json_decode($data));echo "<br/>";$data='var data ={
655199:{
480:[780,2,980],
397:[770,2,990],
596:[770,2,990]
},
655201:{
481:[780,2,980],
398:[770,2,990],
599:[770,2,990]
}
}';$data = preg_replace('/(\d+)/','"$1"',ltrim($data,'var data ='));var_dump(json_decode($data));//End_php