9b45eef7290592e268733f18aaff0503cfa82d4a angie Mon May 13 12:08:31 2019 -0700 jsonQuery: Use netLineFileOpen not lineFileOpen, to support URLs. diff --git src/hg/utils/jsonQuery/jsonQuery.c src/hg/utils/jsonQuery/jsonQuery.c index 8c2f81c..fbee1c8 100644 --- src/hg/utils/jsonQuery/jsonQuery.c +++ src/hg/utils/jsonQuery/jsonQuery.c @@ -1,50 +1,51 @@ /* jsonQuery - Use a path syntax to retrieve elements/values from each line of JSON input. */ #include "common.h" #include "jsHelper.h" #include "jsonQuery.h" #include "linefile.h" +#include "net.h" #include "obscure.h" #include "options.h" void usage() /* Explain usage and exit. */ { errAbort( "jsonQuery - Use a path syntax to retrieve elements/values from each line of JSON input\n" "usage:\n" " jsonQuery input.json path output.js\n" "options:\n" " -uniq Print out unique values as they are found (instead of all values)\n" " -countUniq Print out unique values and the number of times each occurs at end of input\n" "\n" "Except for -uniq and -countUniq modes, objects and lists in output are pretty-printed\n" "with newlines, so they are JavaScript values not JSON.\n" ); } /* Command line validation table. */ static struct optionSpec options[] = { { "uniq", OPTION_BOOLEAN }, { "countUniq", OPTION_BOOLEAN }, { NULL, 0 }, }; void jsonQuery(char *inFile, char *path, char *outFile) /* jsonQuery - Use a path syntax to retrieve elements/values from each line of JSON input. */ { -struct lineFile *lf = lineFileOpen(inFile, TRUE); +struct lineFile *lf = netLineFileOpen(inFile); struct hash *uniqHash = NULL; boolean countUniq = optionExists("countUniq"); boolean uniq = optionExists("uniq") || countUniq; if (uniq) uniqHash = hashNew(0); struct dyString *dy = dyStringNew(0); FILE *outF = mustOpen(outFile, "w"); char *line; while (lineFileNextReal(lf, &line)) { struct lm *lm = lmInit(1<<16); struct jsonElement *topEl = jsonParseLm(line, lm); struct slRef topRef; topRef.next = NULL; topRef.val = topEl;