code: @SuppressWarnings("unchecked")
    private Map<String, Object> convertToMap(Object jsonDocument) {
      Map<String, Object> jsonMap = new LinkedHashMap<>();
  
      // Document is a text block
      if (!(jsonDocument instanceof JSONObject)) {
        jsonMap.put("content", jsonDocument);
        return jsonMap;
      }
  
      JSONObject obj = (JSONObject) jsonDocument;
      for (String key : obj.keySet()) {
        Object value = obj.get(key);
  
        if (value instanceof JSONObject) {
          value = convertToMap(value);
        } else if (value instanceof JSONArray) {
          ArrayList<Map<String, Object>> collection = new ArrayList<>();
  
          for (Object element : ((JSONArray) value)) {
            collection.add(convertToMap(element));
          }
  
          value = collection;
        }
  
        jsonMap.put(key, value);
      }
      return jsonMap;
  
    }
docs: Convert given Json document to a multi-level map.