[PHP]JSON 解析

mixed json_decode ( string $json [, bool $assoc = false [, int $depth = 512 [, int $options = 0]]] )

 

当第二个参数为TRUE时  返回一个数组 

否则返回类

<php?
// 返回stdClass类    
$jsonClass = json_decode($json);
$element1 = $jsonData->element1;
$element2 = $jsonData->element2;


// 返回一个数组
$jsonArray = json_decode($json);
$element01 = $jsonData['element1'];
$element02 = $jsobData['element2'];

?>

 stdClass 由命名来看比较像是一个所有类的基类

posted @ 2015-08-07 22:45  baaingSheep  阅读(195)  评论(0编辑  收藏  举报