私は次のjsonデータを持っています:
var JSONObject2= {
"weather": {
"curren_weather": [
{
"humidity": "69",
"pressure": "1012",
"temp": "70",
"temp_unit": "f",
"weather_code": "1",
"weather_text": "Mostly cloudy",
"wind": [
{
"dir": "Not Available",
"speed": "0",
"wind_unit": "mph"
}
]
}
],
"forecast": [
{
"date": "2012-08-21",
"day": [
{
"weather_code": "0",
"weather_text": "Sunny skies",
"wind": [
{
"dir": "NW",
"dir_degree": "311",
"speed": "7",
"wind_unit": "mph"
}
]
}
],
"day_max_temp": "83",
"night": [
{
"weather_code": "0",
"weather_text": "Clear skies",
"wind": [
{
"dir": "WNW",
"dir_degree": "289",
"speed": "7",
"wind_unit": "mph"
}
]
}
],
"night_min_temp": "57",
"temp_unit": "f"
},
{
"date": "2012-08-22",
"day": [
{
"weather_code": "0",
"weather_text": "Sunny skies",
"wind": [
{
"dir": "N",
"dir_degree": "7",
"speed": "4",
"wind_unit": "mph"
}
]
}
],
"day_max_temp": "85",
"night": [
{
"weather_code": "0",
"weather_text": "Clear skies",
"wind": [
{
"dir": "S",
"dir_degree": "176",
"speed": "7",
"wind_unit": "mph"
}
]
}
],
"night_min_temp": "63",
"temp_unit": "f"
}
]
}
};
非常に単純なjsonデータで、変数を取得する方法を理解できます。上記のようなことで、私には難しいです。
したがって、気温が70の場所にアクセスするには、次のようにコーディングします。var my_temp =Weather.curren_weather.temp//これは機能しません
2つの例と同じように、temp(70)でどのように取得し、wind_degreeが311であるかを言うにはどうすればよいでしょうか。
また、上記のようにjsonオブジェクトを貼り付けることができ、変数にアクセスするために必要な正しいコードを出力するプログラムはありますか?
ありがとう、ジム