Skip to content

Instantly share code, notes, and snippets.

@m0wfo
Created November 7, 2014 14:23
Show Gist options
  • Save m0wfo/23b7b4a13a5f22b75632 to your computer and use it in GitHub Desktop.
Save m0wfo/23b7b4a13a5f22b75632 to your computer and use it in GitHub Desktop.
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS)
public static class Wrapper {
}
@Test
public void testPolymorphicTypeIsReturnedWithoutMap() throws Exception {
Wrapper alertNotifyTag = new Wrapper();
String serialized = mapper.writeValueAsString(alertNotifyTag);
System.out.println(serialized);
assertTrue(serialized.contains("@class"));
}
@Test
public void testTypeIsReturnedWithMap() throws Exception {
Wrapper alertNotifyTag = new Wrapper();
Map<String, Wrapper> map = ImmutableMap.of("something", alertNotifyTag);
String serialized = mapper.writeValueAsString(map);
System.out.println(serialized);
assertTrue(serialized.contains("@class")); // disappears
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment