게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
[질문글]unicode 형태로된 json을 제대로 읽고싶습니다 ..
게시물ID : programmer_14278짧은주소 복사하기
작성자 : 아안돼
추천 : 0
조회수 : 2407회
댓글수 : 3개
등록시간 : 2015/11/05 16:21:40
옵션
  • 본인삭제금지
안녕하세요 .. 현재 이클립스 안드로이드 환경에서 json 을 읽으려다가 계속 좌절중입니다 ..ㅠㅠ
이전에 json을 읽어서 사용해본적이 있기 때문에 쉬울꺼라고 생각했는데 ..
unicode 형태로된 값을 한글로 변환하는 것을 정말 모르겠습니다..
 
일단 json은 http://data.suwon.go.kr/api/action/datastore_search.jsp?resource_id=b06b6552-6ce5-4870-a071-1d2a6c1a1813&limit=1 을 통해서 읽었습니다. 형태는 아래와 같습니다.
 
 
입니다 .. 영어부분은 잘 출력되나 한글부분이 unicode 형태로 나와있습니다.
 
이거를 제가 자바코드로 읽을 때는 
 
HttpClient httpclient = new DefaultHttpClient();
 HttpGet httpget = null;
httpget = new HttpGet("http://data.suwon.go.kr/api/action/datastore_search.jsp?resource_id=b06b6552-6ce5-4870-a071-1d2a6c1a1813");
HttpResponse response=null;
 response = httpclient.execute(httpget);
 HttpEntity entity = response.getEntity();
        
         if (entity != null)
         {
        
             InputStream instream = entity.getContent();   
             String result= convertStreamToString(instream);
	
	}
 
이런 형태로 읽습니다..
 
그리고 convertStreamToString 함수의 내용은
private static String convertStreamToString(InputStream is) throws UnsupportedEncodingException {
     
      BufferedReader reader =    new BufferedReader(new InputStreamReader(is, "UTF-8"));//"EUC-KR" or "UTF-8"
        
      StringBuilder sb = new StringBuilder();
      String line = null;
      try {
          while ((line = reader.readLine()) != null) {
              sb.append(line + "\n");
          }
      } catch (IOException e) {
          e.printStackTrace();
      } finally {
          try {
              is.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
      return sb.toString();
  }
 
입니다 ㅠㅠㅠ
 
지금 문제는 
한글 부분이 유니코드 형태로 출력됩니다..
제가 원하는건 유니코드 형태를 한글로 바꾸고싶은건데 방법을 전혀모르겠습니다 
이틀째 삽질중입니다ㅠㅠ 도움을 주시면 감사하겠습니다
감사합니다 ㅠㅠ
 
 
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호