2015-10-05 105 views
0

我從來沒有與json以前工作,我不確定如何完全。所以基本上我需要得到rgDescriptions表中的所有項目,但我確實不確定如何去做。PHP蒸汽庫存JSon解碼器

所以,如果有人能指出我會朝着正確的方向發展,那就太好了。我試圖尋找關於Json的文檔/教程,但似乎無法找到先進的東西。

只有這樣的東西{"id":"2","instanceID":"8"}

Example of the json I want to decode

+1

的[?我如何從JSON中提取數據與PHP(可能的複製http://stackoverflow.com/questions/29308898/how-do-i-extract -data-from-json-with-php) –

+0

你想從那個json字符串中獲得'id'和'instanceId'? –

+0

我剛剛發佈了我需要解碼的json文本的鏈接。我很掙扎,因爲它有如此多的文字,很難閱讀。 – JnDone

回答

2

使用json_desode()解碼JSON格式。

$json = '{"id":"2","instanceID":"8"}'; 
$decoded = json_decode($json); 
print_r($decoded);// will print decoded format of your json 
echo $decoded->id; // outputs => 2 
echo $decoded->instanceID; // outputs => 8 

Otuput:

stdClass Object 
(
    [id] => 2 
    [instanceID] => 8 
)