您好我正在使用php webservices,我很难接受jsonarray作为帖子请求。我能够容易地接收除jsonarray之外的其他物体。我的json结构如下所示
{
"full_name" :"amn",
"phone":"9902",
"educational_details":[
{"board":"a","grade":"b","percentage":"21.0"},
{"board":"a1","grade":"b1","percentage":"22.0"}
]
}
以下是我的以下解码json的PHP代码
$data = json_decode(file_get_contents('php://input'), true);
$fullname=$data['full_name'];
$phone=$data['phone'];
$email=$data['email'];
$nativeaddress=$data['native_address'];
$fresher=$data['fresher'];
$skills=$data['skills'];
$resumeUri=$data['resume_uri'];
$obj = $data['educational_details'];
$obj1=json_decode($obj,true);
echo "arrayval".$obj1;
任何帮助都将非常感谢..提前致谢:)
答案 0 :(得分:0)
这是上面某人给出的解决方案,并且工作得很好
foreach($obj as $val){
echo "<br>Board = " .$val['board']." <br>Grade = ".$val['grade'] ."<br> Percentage =".$val['percentage'];
$board=$val['board'];
$grade=$val['grade'];
$percentage=$val['percentage'];
$percentageval = floatval($percentage);
}