@Override
  public @Nullable JsonElement toJson(@NotNull Object bean, @Nullable SerializationFilter filter) {
    Object value = accessor.read(bean);
    if (value == null) {
      return null;
    }

    if (value instanceof Element) {
      Element element = (Element)value;
      if (!element.getName().equals(tagName)) {
        element = ((Element)value).clone().setName(tagName);
      }
      return jdomToJson(element);
    }
    if (value instanceof Element[]) {
      Element[] elements = (Element[])value;
      if (elements.length == 0) {
        return null;
      }
      else {
        List<JsonElement> result = new ArrayList<>();
        for (Element element : elements) {
          result.add(jdomToJson(element.getName().equals(tagName) ? element : element.clone().setName(tagName)));
        }
        return new JsonArray(result);
      }
    }
    else {
      return null;
    }
  }
@Override
  public @Nullable JsonElement toJson(@NotNull Object bean, @Nullable SerializationFilter filter)