<?
//data_send.php ------------------
$json_data = '{"kim":{"age":"30","pay":"350"},"lee":{"age":"50","pay":"120"},"park":{"age":"40","pay":"180"}}'; // this json_data is working well
$json_data = json_encode($json_data);
?>
<form action="json_parse.php" method="post">
<input type=hidden name=json_data value=<?=$json_data?> >
<input type="submit">
</form>
<?
//json_parse.php ------------------
$json_data = $_REQUEST[json_data];
$json_data = str_replace('\\', '', $json_data);
$output = json_decode($json_data);
echo $output->{'park'}->{'pay'};
//180 is printed
?>
<?
//data_send2.php ------------------
$json = '{"mem_nm":{"disp":"Name","type":"field","param":"0"},"mem_id":{"disp":"Id","type":"field","param":"1"},"mem_email":{"disp":"E-mail","type":"field","param":"2"},"mem_mobile":{"disp":"Phone","type":"bind","param","1-3|-"},"mem_out_yn":{"disp":"Retire","type":"conv","param":"aaa"},"reg_dt":{"disp":"JoinDate","type":"func","param":"convertDateTime"}}'; //this json_data not work
$json_data = json_encode($json_data);
?>
<form action="json_parse2.php" method="post">
<input type=hidden name=json_data value=<?=$json_data?> >
<input type="submit">
</form>
<?
//json_parse2.php ------------------
$json_data = $_REQUEST[json_data];
$json_data = str_replace('\\', '', $json_data);
$output = json_decode($json_data);
echo $output->{'mem_nm'}->{'type'};
//expect 'field' is printed, but nothig is printed
?>
第二个 json 数据不起作用。
我不知道两个json数据的区别。