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>
16 #include <yaz/backtrace.h>
18 void usage(const char *prog)
20 fprintf(stderr, "%s: [-p]\n", prog);
24 static struct json_node *do_parse_from_stdin(void)
27 WRBUF w = wrbuf_alloc();
34 while ((c = getc(f)) != EOF)
36 json_str = wrbuf_cstr(w);
37 n = json_parse2(json_str, &err_msg, &pos);
40 fprintf(stderr, "JSON parse error: %s\nLeading text was:\n", err_msg);
41 fwrite(json_str, 1, pos, stderr);
42 fprintf(stderr, "^\n");
48 int main(int argc, char **argv)
55 yaz_enable_panic_backtrace(*argv);
56 while ((ret = options("p", argv, argc, &arg)) != YAZ_OPTIONS_EOF)
67 n = do_parse_from_stdin();
72 WRBUF result = wrbuf_alloc();
74 json_write_wrbuf_pretty(n, result);
76 json_write_wrbuf(n, result);
77 puts(wrbuf_cstr(result));
78 wrbuf_destroy(result);
86 * c-file-style: "Stroustrup"
87 * indent-tabs-mode: nil
89 * vim: shiftwidth=4 tabstop=8 expandtab