ColorSaver implements ElementTypeAdapter<Color> { @Override public Color deserialize(JsonElement json, JsonDeserializationContext context) throws JsonParseException { return Color.web(json.getAsString()); }  @Override JsonElement serialize(Color src, JsonSerializationContext context); @Override Color deserialize(JsonElement json, JsonDeserializationContext context);  }
@Test public void testDeserialize() throws Exception { String json = "\"#12345678\""; Color color = gson.fromJson(json, Color.class); assertEquals(Color.web("#12345678"), color); }