0d6d33d299f335d125044e48eac0c995dc62eac6 chinhli Wed Oct 2 15:15:37 2013 -0700 Use slNameAddHead() instead of slNameAddTail() in jsonFindNameRecurse(). Added jsonFindNameUniq() to filter out duplicate name. diff --git src/hg/inc/jsHelper.h src/hg/inc/jsHelper.h index 7f97787..feed6f5 100644 --- src/hg/inc/jsHelper.h +++ src/hg/inc/jsHelper.h @@ -199,24 +199,28 @@ // prints out the "common" globals json hash // This hash is the one utils.js and therefore all CGIs know about void jsonErrPrintf(struct dyString *ds, char *format, ...); // Printf a json error to a dyString for communicating with ajax code; format is: // {"error": error message here} struct jsonElement *jsonParse(char *str); // parse string into an in-memory json representation char *jsonStringEscape(char *inString); /* backslash escape a string for use in a double quoted json string. * More conservative than javaScriptLiteralEncode because * some json parsers complain if you escape & or ' */ -void jsonFindNameRecurse(struct jsonElement *ele, char *jName, struct slName *sn); +void jsonFindNameRecurse(struct jsonElement *ele, char *jName, struct slName **pList); // Search the JSON tree recursively to find all the values associated to -// the name. Value found are added to the tail of the slName list +// the name, and add them to head of the list. struct slName *jsonFindName(struct jsonElement *json, char *jName); // Search the JSON tree to find all the values associated to the name -// and put them into a slName list. The first element of the list is the -// name itself and values are added to the tail of the list. +// and add them to head of the list. + +struct slName *jsonFindNameUniq(struct jsonElement *json, char *jName); +// Search the JSON tree to find all the values associated to the name +// and add them to head of the list. + #endif /* JSHELPER_H */