2012-11-19 2 views
0

저는 Jackson 라이브러리를 사용하여 로컬 json 파일을 구문 분석하고 있습니다.ArrayList를 비 직렬화 할 수 없습니다.

W/System.err(7569): org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of VALUE_NUMBER_INT token 

JSON 파일은 다음과 같습니다 : 버튼을 구문 분석에 밀어 나는 그 오류를

{"surveys":[{"id_survey":"1","question_survey":"Are you happy with the actual government?","answer_yes":"50","answer_no":"20"}],"success":1} 

검색하려면 만드는 방법은 다음과 같습니다

final void gettingJson() { 
    final Thread checkUpdate = new Thread() { 
     public void run() { 
     usersController.init(); 
     final StringBuilder str = new StringBuilder("user : "); 
     for (User u : usersController.findAll()) { 
      str.append("\n").append("ID : ").append(u.getId_survey()); 
      str.append("\n").append("Question : ").append(u.getQuestion_survey()); 
      str.append("\n").append("Yes : ").append(u.getAnswer_yes()); 
      str.append("\n").append("No : ").append(u.getAnswer_no()); 

     } 
     runOnUiThread(new Runnable() { 
       public void run() { 
        displayJson.setText(str.toString()); 
       } 
      }); 

     } 
    }; 
    checkUpdate.start(); 
    } 

추가 할 뭔가가 있나요 코드? 내가 뭐 잘못하고 있니? 도움 주셔서 감사합니다.

+0

클래스 정의와 일치하지 않으면 질문에 답할 수 없습니다. 문제의 클래스가'List'를 기대하지만 JSON에 숫자가 포함되어 있다고 할 수 있습니다. – StaxMan

답변

1

문제가 해결 된 것은 json 파일 "success":1의 해당 문자열 때문이었습니다. 그래서 나는 그것을 제거하고 지금은 모두 괜찮습니다.

+0

예, 잘못된 JSON이 원인입니다. 일반적으로 빠른 PHP 스크립트를 사용하여 JSON을 생성하므로 유효하다는 것을 알고 있습니다. – Webnet

관련 문제