{ "result": { "message": "성공", "code": 9200, "requestUrl": "/weather/summary?version=1&lat=37.4930444&lon=127.0137737" }, "common": { "alertYn": "Y", "stormYn": "N" }, "weather": { "summary": [ { "grid": { "latitude": "37.4876400000", "longitude": "126.9879200000", "city": "서울", "county": "서초구", "village": "방배4동" }, "yesterday": { "sky": { "name": "맑음", "code": "SKY_Y01" }, "precipitation": { "rain": "0.00", "snow": "0.00" }, "temperature": { "tmax": "15.10", "tmin": "10.50" } }, "today": { "sky": { "name": "맑음", "code": "SKY_D01" }, "temperature": { "tmax": "15.10", "tmin": "10.50" } }, "tomorrow": { "sky": { "name": "맑음", "code": "SKY_M01" }, "temperature": { "tmax": "15.10", "tmin": "10.50" } }, "dayAfterTomorrow": { "sky": { "name": "맑음", "code": "SKY_M01" }, "temperature": { "tmax": "15.10", "tmin": "10.50" } }, "timeRelease": "2013-11-0717: 00: 00" } ] }}yesterday->sky->name 값을 출력하고 싶은데 잘 안되네요.
에고 어깨넘어로 배워서 군데군데 막히네요.
고수님 좀 도와주세요. 고맙습니다.
|
답변 1개 / 댓글 1개
채택된 답변
+20 포인트
Copy
$json_str = '{ "result": { "message": "성공", "code": 9200, "requestUrl": "/weather/summary?version=1&lat=37.4930444&lon=127.0137737" }, "common": { "alertYn": "Y", "stormYn": "N" }, "weather": { "summary": [ { "grid": { "latitude": "37.4876400000", "longitude": "126.9879200000", "city": "서울", "county": "서초구", "village": "방배4동" }, "yesterday": { "sky": { "name": "맑음", "code": "SKY_Y01" }, "precipitation": { "rain": "0.00", "snow": "0.00" }, "temperature": { "tmax": "15.10", "tmin": "10.50" } }, "today": { "sky": { "name": "맑음", "code": "SKY_D01" }, "temperature": { "tmax": "15.10", "tmin": "10.50" } }, "tomorrow": { "sky": { "name": "맑음", "code": "SKY_M01" }, "temperature": { "tmax": "15.10", "tmin": "10.50" } }, "dayAfterTomorrow": { "sky": { "name": "맑음", "code": "SKY_M01" }, "temperature": { "tmax": "15.10", "tmin": "10.50" } }, "timeRelease": "2013-11-0717: 00: 00" } ] }}';$obj = json_decode($json_str); echo $obj->weather->summary[0]->yesterday->sky->name;
답변에 대한 댓글 1개
2017-04-11 (화) 08:43:29
답변을 작성하려면 로그인이 필요합니다.
역시 고수님이십니다. 꾸벅~~