안드로이드 개발 질문/답변
(글 수 45,052)
HttpResponse response = client.execute(request);
BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));String tempStr = "";StringBuilder builder = new StringBuilder();
// 구글링에선 JSON 줄바꿈 때문에 제대로된 파싱이 안된다고 함.
while ((tempStr = in.readLine()) != null) {
builder.append(tempStr);
Log.d("api", "htmlSource appended=" + htmlSource.toString()
);
}
JSON파싱을 위와같이 시도하고 있습니다.
총 3가지 Array에서 값을 가져오는데, 가운데 부분에 값 부분에 정체모를 에러가 찍혀서 나옵니다..
이곳저곳 보니, JSON new line 추가 때문에 이것을 잡아줘야 한다고 하더라구요..
근데 대체 뭘 잡아내고 어떤식으로 써야하는지.. 잘 모르겠습니다.
사실 왜 줄바꿈되어서 builder.append() 되는지 잘 모르겠네요 ;;
아래는 에러입니다.
org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]"}]




while ((tempStr = in.readLine()) != null)
이 방법으로 readLine()하는 방법이 잘못된 걸까요..?
대체 왜 JSON이 두줄이 되어서 String에 담아지는지 이해불가능...-.-