與大多數(shù)流行的 Web 服務(wù)如 twitter 通過開放 API 來提供數(shù)據(jù)一樣,它總是能夠知道如何解析 API 數(shù)據(jù)的各種傳送格式,包括 JSON,XML 等等。
$json_string='{"id":1,"name":"foo","email":"foo@foobar.com","interest":["wordpress","php"]} ';
$obj=json_decode($json_string);
echo $obj->name; //prints foo
echo $obj->interest[1]; //prints php