Frage

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.

War es hilfreich?

Lösung

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.

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top