TileSizeSaver implements ElementTypeAdapter<TileSize> { @Override public JsonElement serialize(TileSize src, JsonSerializationContext context) { JsonArray array = new JsonArray(2); array.add(src.getWidth()); array.add(src.getHeight()); return array; }  @Override JsonElement serialize(TileSize src, JsonSerializationContext context); @Override TileSize deserialize(JsonElement json, JsonDeserializationContext context);  }
@Test public void serialize() throws Exception { String json = gson.toJson(new TileSize(1, 2)); assertEquals("[1,2]", json); }