2016-10-05 7 views
0

json配列がリストに含まれている場合、ファイルリストからデータを取得するにはどうすればよいですか?例えば。リスト内のAzure Stream Analiticsリスト

{"city":{"id":1851632,"name":"Shuzenji", 
"coord":{"lon":138.933334,"lat":34.966671}, 
"country":"JP", 
"cod":"200", 
"message":0.0045, 
"cnt":38, 
"list":[{ 
     "dt":1406106000, 
     "main":{ 
      "temp":298.77, 
      "temp_min":298.77, 
      "temp_max":298.774, 
      "pressure":1005.93, 
      "sea_level":1018.18, 
      "grnd_level":1005.93, 
      "humidity":87 
      "temp_kf":0.26}, 
     "weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}], 
     "clouds":{"all":88}, 
     "wind":{"speed":5.71,"deg":229.501}, 
     "sys":{"pod":"d"}, 
     "dt_txt":"2014-07-23 09:00:00"} 
     ]} 

weather.mainにはどのように連絡しますか?

答えて

0

まず、あなたのJSON形式は、のは、これらの最初の問題を修正しましょう、エラーを持っているように見える:湿度行の末尾の後に

{"city":{"id":1851632,"name":"Shuzenji"}, 
"coord":{"lon":138.933334,"lat":34.966671}, 
"country":"JP", 
"cod":"200", 
"message":0.0045, 
"cnt":38, 
"list":[{ 
     "dt":1406106000, 
     "main":{ 
      "temp":298.77, 
      "temp_min":298.77, 
      "temp_max":298.774, 
      "pressure":1005.93, 
      "sea_level":1018.18, 
      "grnd_level":1005.93, 
      "humidity":87, 
      "temp_kf":0.26}, 
     "weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}], 
     "clouds":{"all":88}, 
     "wind":{"speed":5.71,"deg":229.501}, 
     "sys":{"pod":"d"}, 
     "dt_txt":"2014-07-23 09:00:00"} 
     ]}, 

注意コンマ、および修善寺後の最初の行にレコードを閉じました。

JSONのweather.mainの例では、実際にはlist[0].weather[0].mainです。ここでArrayRecord組み込み関数を使用してJSONの構造のうち、正確にこの値 を取得する方法である:

SELECT 
    -- input.list[0].weather[0].main 
    WeatherMain = GetRecordPropertyValue(GetArrayElement(GetRecordPropertyValue(GetArrayElement(input.list, 0), 'weather'), 0), 'main') 
FROM input 
+0

はあなたの助けをいただき、ありがとうございます。 – Kamil