I want to serialize a Map<MyObject, ...>. This is not currently possible
because these are serialized into:
{"<myObject1.toString()>" : ..., "<myObject2.toString()>" : ..., ...}
which is obviously not reversible back into my MyObject instances.
I was able to fix this problem by writing a custom adapter that simply
transforms the Map into a List on serialization and back into a Map on
deserialization, but this is a pain when otherwise I can serialize a huge
object hierarchy very simply.
e.g., I made the above serialize to [{"k" : myObject1, "v" : ...}, {"k" :
myObject2, "v" : ...}, ...]
I propose that DefaultMapTypeAdapter use something like this List approach by
default, unless the key value happens to be a String, since there is really
nothing else particularly sane it can do without losing a ton of information in
doing the String.valueOf() call.
Original issue reported on code.google.com by jsha...@google.com on 26 Aug 2010 at 9:02
Original issue reported on code.google.com by
jsha...@google.com
on 26 Aug 2010 at 9:02