162b8c5fb261a7dad0d62c57e82236b0b676a473
larrym
  Wed Jul 13 17:09:17 2011 -0700
make jsPrintHash print json compliant output
diff --git src/hg/lib/jsHelper.c src/hg/lib/jsHelper.c
index 28fc2b9..987f2f1 100644
--- src/hg/lib/jsHelper.c
+++ src/hg/lib/jsHelper.c
@@ -516,24 +516,25 @@
 
 void jsPrintHash(struct hash *hash, char *name, int indentLevel)
 {
 // prints a hash as a javascript variable
 
 int i;
 char *indentBuf;
 indentBuf = needMem(indentLevel + 1);
 for (i = 0; i < indentLevel; i++)
     indentBuf[i] = '\t';
 indentBuf[i] = 0;
 if(hashNumEntries(hash))
     {
     struct hashEl *el, *list = hashElListHash(hash);
     slSort(&list, hashElCmp);
-    hPrintf("%svar %s = {\n", indentBuf, name);
+    // We add START and END comments to facilitate scraping out this variable by javascript.
+    hPrintf("// START %s\n%svar %s = {\n", name, indentBuf, name);
     for (el = list; el != NULL; el = el->next)
         {
-        hPrintf("%s\t%s: %s%s\n", indentBuf, el->name, (char *) el->val, el->next == NULL ? "" : ",");
+        hPrintf("%s\t\"%s\": %s%s\n", indentBuf, el->name, (char *) el->val, el->next == NULL ? "" : ",");
         }
-    hPrintf("%s};\n", indentBuf);
+    hPrintf("%s};\n// END %s\n", indentBuf, name);
     hashElFreeList(&list);
     }
 }