質問

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.

役に立ちましたか?

解決

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.

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top