stdClass Object
(
[from] => zh
[to] => en
[trans_result] => Array
(
[0] => stdClass Object
(
[src] => 你好
[dst] => Hello
)
)
)
我们在PHP语言中可以用以下方法取得我们想要的值:
代码如下 复制代码
<?php
$data = <<<STR
{
"from":"zh",
"to":"en",
"trans_result":[
{
"src":"u4f60u597d",
"dst":"Hello"
}
]
}
STR;
$jsondata=json_decode($data);
header("Content-Type: text/html; charset=UTF-8");
print_r($jsondata);
echo "<br />".$jsondata->from; //zh
echo "<br />".$jsondata->trans_result[0]->src; //你好
?>