docs: @Override
    public QueryAggregation deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException {
      JsonReader in = new JsonReader(new StringReader(GsonSingleton.getGson().toJson(json)));
      HashMap<String, Object> aggregationMap = null;
  
      try {
        aggregationMap = getAggregationMap(in);
      } catch (IOException e) {
        e.printStackTrace();
      }
  
      QueryAggregation aggregation;
      String aggregationType = (String) aggregationMap.get(TYPE);
  
      if (aggregationType.equals(AggregationType.HISTOGRAM.getName())) {
        aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Histogram.class);
      } else if (aggregationType.equals(AggregationType.MAX.getName())
          || aggregationType.equals(AggregationType.MIN.getName())
          || aggregationType.equals(AggregationType.AVERAGE.getName())
          || aggregationType.equals(AggregationType.SUM.getName())
          || aggregationType.equals(AggregationType.UNIQUE_COUNT.getName())) {
        aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Calculation.class);
      } else if (aggregationType.equals(AggregationType.TERM.getName())) {
        aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Term.class);
      } else if (aggregationType.equals(AggregationType.FILTER.getName())) {
        aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Filter.class);
      } else if (aggregationType.equals(AggregationType.NESTED.getName())) {
        aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Nested.class);
      } else if (aggregationType.equals(AggregationType.TIMESLICE.getName())) {
        aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Timeslice.class);
      } else if (aggregationType.equals(AggregationType.TOP_HITS.getName())) {
        aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, TopHits.class);
      } else {
        aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, QueryAggregation.class);
      }
  
      return aggregation;
    }