@SuppressWarnings("unchecked")
  public Map<?, ?> read(Json json, JsonValue jsonData) {

    Map<K, V> values;

    try {
      values = (Map<K, V>) map.map().newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      throw new GdxRuntimeException(e);
    }

    JsonValue entry = jsonData.getChild(name);

    while (entry != null) {

      JsonValue keyValue = entry.get("key");
      K key = json.readValue((Class<K>) map.key(), keyValue);

      JsonValue valueValue = entry.get("value");
      V value = json.readValue((Class<V>) map.value(), valueValue);

      values.put(key, value);

      entry = entry.next;
    }

    return values;
  }
  @SuppressWarnings("unchecked")
  public <M> M read(
      Json json, JsonValue jsonData, Supplier<M> newInstance, KeyValueConsumer<M, K, V> put) {

    M values = newInstance.get();

    JsonValue entry = jsonData.getChild(name);

    while (entry != null) {

      JsonValue keyValue = entry.get("key");
      K key = json.readValue((Class<K>) map.key(), keyValue);

      JsonValue valueValue = entry.get("value");
      V value = json.readValue((Class<V>) map.value(), valueValue);

      put.accept(values, key, value);

      entry = entry.next;
    }

    return values;
  }