class TileSizeSaver implements ElementTypeAdapter<TileSize> {

  @Override
  public TileSize deserialize(JsonElement json, JsonDeserializationContext context) throws JsonParseException {
    int width = json.getAsJsonArray().get(0).getAsInt();
    int height = json.getAsJsonArray().get(1).getAsInt();
    try {
      return new TileSize(width, height);
    } catch (IllegalArgumentException e) {
      throw new JsonParseException("Illegal TileSize. Expected positive integers, found " + json.getAsString(), e);
    }
  }

}