d2429b17bb096f6c406a2ae03fb5593f27fa53c1
hiram
  Mon Mar 18 14:17:07 2019 -0700
hash up the output properly for hubPublic and dbDb outputs refs #18869

diff --git src/hg/hubApi/apiUtils.c src/hg/hubApi/apiUtils.c
index 1b14c36..e1f6764 100644
--- src/hg/hubApi/apiUtils.c
+++ src/hg/hubApi/apiUtils.c
@@ -12,52 +12,63 @@
 struct jsonWrite *jw = apiStartOutput();
 jsonWriteString(jw, "error", errMsg);
 jsonWriteObjectEnd(jw);
 fputs(jw->dy->string,stdout);
 exit(0);
 }
 
 struct jsonWrite *apiStartOutput()
 /* begin json output with standard header information for all requests */
 {
 time_t timeNow = time(NULL);
 // struct tm tm;
 // gmtime_r(&timeNow, &tm);
 struct jsonWrite *jw = jsonWriteNew();
 jsonWriteObjectStart(jw, NULL);
-jsonWriteString(jw, "apiVersion", "v"CGI_VERSION);
+// not recommended: jsonWriteString(jw, "apiVersion", "v"CGI_VERSION);
 jsonWriteString(jw, "source", "UCSantaCruz");
 jsonWriteDateFromUnix(jw, "downloadTime", (long long) timeNow);
 jsonWriteNumber(jw, "downloadTimeStamp", (long long) timeNow);
 return jw;
 }
 
-int tableColumns(struct sqlConnection *conn, struct jsonWrite *jw, char *table)
-/* output the column names, and their MySQL data type, for the given table
+int tableColumns(struct sqlConnection *conn, struct jsonWrite *jw, char *table,
+   char ***nameReturn, char ***typeReturn)
+/* return the column names, and their MySQL data type, for the given table
  *  return number of columns (aka 'fields')
  */
 {
-jsonWriteListStart(jw, "columnNames");
+// not needed jsonWriteListStart(jw, "columnNames");
 struct sqlFieldInfo *fi, *fiList = sqlFieldInfoGet(conn, table);
 int columnCount = slCount(fiList);
+char **namesReturn = NULL;
+char **typesReturn = NULL;
+AllocArray(namesReturn, columnCount);
+AllocArray(typesReturn, columnCount);
+int i = 0;
 for (fi = fiList; fi; fi = fi->next)
     {
-    jsonWriteObjectStart(jw, NULL);
-    jsonWriteString(jw, fi->field, fi->type);
-    jsonWriteObjectEnd(jw);
+    namesReturn[i] = cloneString(fi->field);
+    typesReturn[i] = cloneString(fi->type);
+    i++;
+// not needed     jsonWriteObjectStart(jw, NULL);
+// not needed     jsonWriteString(jw, fi->field, fi->type);
+// not needed     jsonWriteObjectEnd(jw);
     }
-jsonWriteListEnd(jw);
+// not needed jsonWriteListEnd(jw);
+*nameReturn = namesReturn;
+*typeReturn = namesReturn;
 return columnCount;
 }
 
 struct trackHub *errCatchTrackHubOpen(char *hubUrl)
 /* use errCatch around a trackHub open in case it fails */
 {
 struct trackHub *hub = NULL;
 struct errCatch *errCatch = errCatchNew();
 if (errCatchStart(errCatch))
     {
     hub = trackHubOpen(hubUrl, "");
     }
 errCatchEnd(errCatch);
 if (errCatch->gotError)
     {