杰克逊JSON处理器故障

时间:2014-11-04 16:00:28

标签: java android json object jackson

我在课堂上有一个方法:

public MyClass readMyObject(Activity activity) {
        MyClass myClass = null;
        try {
            myClass = new MyClass();
            SharedPreferences prefs = activity.getApplicationContext().getSharedPreferences("myClass", Context.MODE_PRIVATE);
            String preferences = prefs.getString("myClass", "0");
            ObjectMapper mapper = new ObjectMapper();
            byte[] byteTemp = mapper.readValue(preferences, byte[].class);
            ByteArrayInputStream in = new ByteArrayInputStream(byteTemp);
            ObjectInputStream is = new ObjectInputStream(in);
            myClass = (MyClass) is.readObject();
            } catch (JsonParseException e) {
            } catch (IOException e) {
            } catch (ClassNotFoundException e) {
            }
        return myClass;
    }

以下是我得到的例外

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/fasterxml/jackson/databind/ObjectMapper;

我用:

  • jackson-core-2.4.2.jar
  • 杰克逊 - 注解-2.4.2.jar
  • 杰克逊 - 数据绑定-2.4.2.jar

我的应用程序的目标是Android 5.0。 谢谢!

0 个答案:

没有答案