dbd8fef5786457ba53375f006c4eaedf3d256110 hiram Fri Apr 5 11:46:55 2019 -0700 now output correct string or number json types refs #18869 diff --git src/hg/hubApi/dataApi.h src/hg/hubApi/dataApi.h index a27ed43..befb808 100644 --- src/hg/hubApi/dataApi.h +++ src/hg/hubApi/dataApi.h @@ -45,34 +45,46 @@ boolean debug; /* can be set in URL debug=1, to turn off: debug=0 */ /* functions in hubApi.c */ struct hubPublic *hubPublicDbLoadAll(); struct dbDb *ucscDbDb(); /* return the dbDb table as an slList */ /* functions in apiUtils.c */ void apiErrAbort(char *format, ...); /* Issue an error message in json format, and exit(0) */ struct jsonWrite *apiStartOutput(); /* begin json output with standard header information for all requests */ +extern char *jsonTypeStrings[]; +#define JSON_STRING 0 // "string", /* type 0 */ +#define JSON_NUMBER 1 // "number", /* type 1 */ +#define JSON_OBJECT 2 // "object", /* type 2 */ +#define JSON_ARRAY 3 // "array", /* type 3 */ +#define JSON_BOOLEAN 4 // "boolean", /* type 4 */ +#define JSON_NULL 5 // "null" /* type 5 */ +#define JSON_DOUBLE 6 // UCSC json type double /* type 6 */ + +int autoSqlToJsonType(char *asType); +/* convert an autoSql field type to a Json type */ + 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') + char ***nameReturn, char ***typeReturn, int **jsonTypes); +/* return the column names, the MySQL data type, and json data type + * for the given table return number of columns (aka 'fields') */ struct trackHub *errCatchTrackHubOpen(char *hubUrl); /* use errCatch around a trackHub open in case it fails */ struct trackDb *obtainTdb(struct trackHubGenome *genome, char *db); /* return a full trackDb fiven the hub genome pointer, or ucsc database name */ struct trackDb *findTrackDb(char *track, struct trackDb *tdb); /* search tdb structure for specific track, recursion on subtracks */ struct bbiFile *bigFileOpen(char *trackType, char *bigDataUrl); /* open bigDataUrl for correct trackType and error catch if failure */ int chromInfoCmp(const void *va, const void *vb);