
JSON파싱 고생하며 해서... 위와 같이 간단한 현재 날씨를 구현했습니다..
외국 서비스라 그런지 영어로 표기가 되는데, 이걸 language를 한글로 바꿔줄 수는 없을까요?
쿼리문에서 u='c'라고 넣어주니까 화씨를 섭씨로 바꿔주던데
영어를 한글로 바꿔주는 쿼리 명령어가 있다면 참 좋겠습니다
@Override
protected String doInBackground(String... strings) {
//야후 쿼리문
String YQL = String.format("select * from weather.forecast where woeid in (select woeid from geo.places(1) where text=\"%s\") and u='c'", strings[0]);
//야후 쿼리문을 이용한 야후 API
String endpoint = String.format("https://query.yahooapis.com/v1/public/yql?q=%s&format=json", Uri.encode(YQL));
try {
URL url = new URL(endpoint);
//야후 API 이용하여 네트워크 접속
URLConnection connection = url.openConnection();
InputStream inputStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder result = new StringBuilder();
String line;
while((line = reader.readLine()) != null)
{
result.append(line);
}
return result.toString();
} catch (Exception e) {
error = e;
}
return null;
}