문제

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