Domanda

I have server written in java SE, and a client is written in android, when I serialize an object Map in the client and then I pass it to the server and the server can't deserialize the object and vice versa. So, when I'm trying to deserialize another object like String, or Date, that's working fine.

È stato utile?

Soluzione

Maps should usually be avoided in interfaces, especially when it involves serialization.

Instead, try to replace your map by an other data structure containing the same data.

For instance, create an object like:

public class MyObject implements Serializable {
    Key keyOfMap;
    Value valueOfMap;
}

And send a List<MyObject> or equivalent.

This should avoid all your map problems.

Altri suggerimenti

HashMap itself is Serializable. The problem is that all keys / values it contains must be Serializable too if you want to serialize this map instance.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top