How to serialize and deserialize list of object arrays with flexjson?

2k views Asked by At

does anybody know how to serialize and deserialize a list of object arrays with flexjson?

What I have tried is this:

@GET 
@Produces(MediaType.APPLICATION_JSON)
@Path("/getAllGeoData")
public String getAllGeoData(){
    List<Object[]>l = geoMapService.getAllGeoData();

    return new JSONSerializer().serialize(l);
}

Okay .. this works and when I call this webservice I get the following result:

[[50.0830292,8.2387331],[50.0830292,8.2387331],[50.0752003,8.2397125]]

In my Android Client I try to deserialize that List of Objects:

List<Object[]> l=new  JSONDeserializer<List<Object[]>>().deserialize(jsonstring);

and I get the following execption:

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)

Help would be appreciated

Greetings

1

There are 1 answers

7
Heiko Rupp On

It looks like the version of the flexjson package you supplied is not compatible with your android version. Did you add this to the libs/ directory of the app?

Flexjson 2.1 is supposed to work on Android according to this (scroll to the bottom).

As org.json package is "built in" into Android, would it be a viable way to just use that package instead?