code: public String toDependencyString(CmsObject cms) {
  
          JSONObject jsonDoc = toJSON(cms, true);
  
          try {
              if ((!isAttachment()) && (m_attachments != null)) {
                  // iterate through all attachments
                  JSONArray jsonAttachments = new JSONArray();
                  for (CmsDocumentDependency att : m_attachments) {
                      JSONObject jsonAttachment = att.toJSON(cms, true);
                      jsonAttachments.put(jsonAttachment);
                  }
                  jsonDoc.put(JSON_ATTACHMENTS, jsonAttachments);
              } else if (isAttachment()) {
                  CmsDocumentDependency main = getMainDocument();
                  if (main != null) {
                      JSONObject jsonMain = main.toJSON(cms, true);
                      // iterate through all attachments of the main document
                      List<CmsDocumentDependency> attachments = main.getAttachments();
                      if (attachments != null) {
                          JSONArray jsonAttachments = new JSONArray();
                          for (CmsDocumentDependency att : attachments) {
                              JSONObject jsonAttachment = att.toJSON(cms, true);
                              jsonAttachments.put(jsonAttachment);
                          }
                          jsonMain.put(JSON_ATTACHMENTS, jsonAttachments);
                      }
                      jsonDoc.put(JSON_MAIN, jsonMain);
                  }
              }
              return jsonDoc.toString();
          } catch (JSONException e) {
              if (LOG.isErrorEnabled()) {
                  LOG.error(e.getLocalizedMessage(), e);
              }
          }
          return null;
      }
docs: Creates the String representation of this dependency object.<p>
  
  @param cms the current OpenCms user context
  
  @return the String representation of this dependency object