What steps will reproduce the problem?
@Test
public final void testInterfaceTypeMap() {
MapClass element = new MapClass();
element.addSerializable("Test", "I am invisible!");
element.addStrings("Test", "I am visible!");
GsonBuilder builder = new GsonBuilder();
Gson creator = builder.create();
String json = creator.toJson(element);
assertEquals("{\"serializables\":{\"Test\":\"I am invisible!\"},\"strings\":{\"Test\":\"I am visible!\"}}", json);
}
static final class MapClass {
private Map<String, Serializable> serializables = Maps.newHashMap();
private Map<String, String> strings = Maps.newHashMap();
public final void addSerializable(final String name, final Serializable value) {
this.serializables.put(name, value);
}
public final void addStrings(final String name, final String value) {
this.strings.put(name, value);
}
}
What is the expected output? What do you see instead?
Expected: {"serializables":{"Test":"I am invisible!"},"strings":{"Test":"I am
visible!"}}
What I see: {"serializables":{"Test":{}},"strings":{"Test":"I am visible!"}}
What version of the product are you using? On what operating system?
1.6 on Ubuntu Linux
Please provide any additional information below.
Unit test should be sufficient I hope... :)
Original issue reported on code.google.com by chea...@gmail.com on 23 Mar 2011 at 10:21
Original issue reported on code.google.com by
chea...@gmail.com
on 23 Mar 2011 at 10:21