日期:2014-05-17 浏览次数:20509 次
//组合医生信息JSON
$jsonDoctorInfo = "{\"mecdoctor\":[";
$jsonDoctorInfo .= "{\"doctorId\":\"".$doctorId."\",\"doctorName\":\"".$strDoctorName."\", \"doctorprice\":\"".$strPrice."\",\"expertise\":\"".$strExpertise."\",\"departments\":\"".$strdepartments."\",\"doctorTitle\":\"".$strTitle."\",\"doctorPhoto\":\"".$strDoctorPhoto."\"}";
$jsonDoctorInfo .= "]}";
{"mecdoctor":[{"doctorId":"","doctorName":"XXXX", "doctorprice":"122","expertise":"XXXXX","departments":"医内科","doctorTitle":"主任医师","doctorPhoto":"hmh"}]}
//解析JSON数据
function _json_decode($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;
}
$s = '{"mecdoctor":[{"doctorId":"","doctorName":"XXXX", "doctorprice":"122","expertise":"XXXXX","departments":"医内科","doctorTitle":"主任医师","doctorPhoto":"hmh"}]}';
print_r(_json_decode($s));
function _json_decode($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] == '}')
------解决方案--------------------<