2016-04-16 115 views
-3

我想在PHP中解析這個JSON。我不知道如何解析數據它:我想解析PHP中的這個JSON

stdClass Object ( 
    [coord] => stdClass Object ( 
     [lon] => 138.93 
     [lat] => 34.97 
    ) 
    [weather] => Array (
     [0] => stdClass Object ( 
     [id] => 803 
     [main] => Clouds 
     [description] => broken clouds 
     [icon] => 04n 
    ) 
    ) 
    [base] => stations 
    [main] => stdClass Object ( 
     [temp] => 290.738 
     [pressure] => 1026.59 
     [humidity] => 94 
     [temp_min] => 290.738 
     [temp_max] => 290.738 
     [sea_level] => 1035.92 
     [grnd_level] => 1026.59) 
     [wind] => 
     stdClass Object ( 
      [speed] => 6.81 
      [deg] => 225.502) 
      [clouds] => stdClass Object ( 
      [all] => 56) 
      [dt] => 1460799951 
      [sys] => stdClass Object ( 
      [message] => 0.0131 
      [country] => JP 
      [sunrise] => 1460751040 
      [sunset] => 1460798268 
     ) 
      [id] => 1851632 
      [name] => Shuzenji 
      [cod] => 200 
    ) 
+0

我不知道任何PHP或JSON,但我可以downvote這:( –

+0

這不是JSON。 –

+0

好吧,那麼如何把主要部分? –

回答

1

這不是jSON,它是一個PHP對象。

要取回它,你可以使用->這樣的例子。說它是$data var和你想獲得天氣陣列:

$weather = $data -> weather; // retrieve weather array 

要獲得main對象的一部分,你可以根據以下步驟做:

$mainObject = $data -> main; // retrieve main Object 
$temp = $data -> main -> temp; // retrieve temp from main Object 
+0

更多規格plz –

+0

我想採取主要對象的部分,然後什麼要做什麼? –

+0

你好,非常感謝你, –