有人知道如何使用flexjson序列化和反序列化对象数组列表吗?
我试过的是:
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/getAllGeoData")
public String getAllGeoData(){
List<Object[]>l = geoMapService.getAllGeoData();
return new JSONSerializer().serialize(l);
}
好的..这很有效,当我调用这个web服务时,我得到以下结果:
[[50.0830292,8.2387331],[50.0830292,8.2387331],[50.0752003,8.2397125]]
在我的Android客户端中,我尝试反序列化该对象列表:
List<Object[]> l=new JSONDeserializer<List<Object[]>>().deserialize(jsonstring);
我得到以下的执行:
02-23 09:45:30.911: WARN/dalvikvm(270): VFY: unable to resolve exception class 157 (Ljava/beans/IntrospectionException;)
02-23 09:45:30.921: WARN/dalvikvm(270): VFY: unable to resolve exception class 157 (Ljava/beans/IntrospectionException;)
02-23 09:45:30.921: WARN/dalvikvm(270): VFY: unable to find exception handler at addr 0x16a
02-23 09:45:30.921: WARN/dalvikvm(270): VFY: rejected Lflexjson/ObjectBinder;.bindIntoObject (Ljava/util/Map;Ljava/lang/Object;Ljava/lang/reflect/Type;)Ljava/lang/Object;
02-23 09:45:30.921: WARN/dalvikvm(270): VFY: rejecting opcode 0x0d at 0x016a
02-23 09:45:30.931: WARN/dalvikvm(270): VFY: rejected Lflexjson/ObjectBinder;.bindIntoObject (Ljava/util/Map;Ljava/lang/Object;Ljava/lang/reflect/Type;)Ljava/lang/Object;
02-23 09:45:30.931: WARN/dalvikvm(270): Verifier rejected class Lflexjson/ObjectBinder;
02-23 09:45:30.941: WARN/dalvikvm(270): threadid=15: thread exiting with uncaught exception (group=0x4001b188)
02-23 09:45:30.941: ERROR/AndroidRuntime(270): Uncaught handler: thread Thread-8 exiting due to uncaught exception
02-23 09:45:30.951: ERROR/AndroidRuntime(270): java.lang.VerifyError: flexjson.ObjectBinder
02-23 09:45:30.951: ERROR/AndroidRuntime(270): at flexjson.JSONDeserializer.createObjectBinder(JSONDeserializer.java:169)
02-23 09:45:30.951: ERROR/AndroidRuntime(270): at flexjson.JSONDeserializer.deserialize(JSONDeserializer.java:149)
02-23 09:45:30.951: ERROR/AndroidRuntime(270): at com.mobilesociato.services.RemoteServiceGeoData$GeoDataThread.run(RemoteServiceGeoData.java:76)
02-23 09:45:30.951: ERROR/AndroidRuntime(270): at java.lang.Thread.run(Thread.java:1096)
帮助将不胜感激
问候
答案 0 :(得分:0)
看起来您提供的flexjson软件包的版本与您的Android版本不兼容。您是否将此添加到应用程序的libs /目录中?
Flexjson 2.1应该可以根据to this在Android上运行(滚动到底部)。
由于org.json
包是&#34;内置&#34;进入Android,是否只是使用该软件包的可行方式?