1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) Index Data
3 * See the file LICENSE for details.
14 #include <yaz/wrbuf.h>
15 #include <yaz/options.h>
17 void usage(const char *prog)
19 fprintf(stderr, "%s: [-p]\n", prog);
23 static struct json_node *do_parse_from_stdin(void)
26 WRBUF w = wrbuf_alloc();
33 while ((c = getc(f)) != EOF)
35 json_str = wrbuf_cstr(w);
36 n = json_parse2(json_str, &err_msg, &pos);
39 fprintf(stderr, "JSON parse error: %s\nLeading text was:\n", err_msg);
40 fwrite(json_str, 1, pos, stderr);
41 fprintf(stderr, "^\n");
47 int main(int argc, char **argv)
53 while ((ret = options("p", argv, argc, &arg)) != YAZ_OPTIONS_EOF)
64 n = do_parse_from_stdin();
69 WRBUF result = wrbuf_alloc();
71 json_write_wrbuf_pretty(n, result);
73 json_write_wrbuf(n, result);
74 puts(wrbuf_cstr(result));
75 wrbuf_destroy(result);
83 * c-file-style: "Stroustrup"
84 * indent-tabs-mode: nil
86 * vim: shiftwidth=4 tabstop=8 expandtab