public Object createObjectFromJsonElement(JsonElement value) {

    if (value == null) {
      return null;
    }

    if (value instanceof JsonPrimitive) {
      JsonPrimitive primitive = (JsonPrimitive) value;

      if (primitive.isBoolean()) {
        return primitive.getAsBoolean();
      }

      if (primitive.isNumber()) {
        return primitive.getAsNumber();
      }

      if (primitive.isString()) {
        return primitive.getAsString();
      }
    }

    if (value instanceof JsonArray) {

      JsonArray array = (JsonArray) value;

      List<Object> values = new ArrayList<Object>();
      for (JsonElement element : array) {
        values.add(createObjectFromJsonElement(element));
      }

      return values;
    }

    if (value instanceof JsonObject) {
      return createObjectFromJsonElement(value);
    }

    throw new RuntimeException("Unrecognized json element: " + value);
  }