无法反序列化ArrayList

时间:2012-11-19 13:36:21

标签: android jackson

我正在使用Jackson库来解析本地json文件。 当按下解析按钮时我有错误:

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();
    }

代码中是否有添加内容?难道我做错了什么? 谢谢你的帮助。

1 个答案:

答案 0 :(得分:1)

问题解决了,这是由于json文件"success":1中的字符串。所以我删除它,现在一切都很好。