ASCII output with every non-ASCII character replaced with the
equivalent escape sequence.
+ * `--unbuffered`
+
+ Flush the output after each JSON object is printed (useful if
+ you're piping a slow data source into jq and piping jq's
+ output elsewhere).
+
* `--sort-keys` / `-S`:
Output the fields of each object with the keys in sorted order.
int jv_get_refcnt(jv);
-enum { JV_PRINT_PRETTY = 1, JV_PRINT_ASCII = 2, JV_PRINT_COLOUR = 4, JV_PRINT_SORTED = 8 };
+enum { JV_PRINT_PRETTY = 1, JV_PRINT_ASCII = 2, JV_PRINT_COLOUR = 4, JV_PRINT_SORTED = 8, JV_PRINT_UNBUFFERED = 16 };
void jv_dump(jv, int flags);
jv jv_dump_string(jv, int flags);
jvp_dtoa_context_init(&C);
jv_dump_term(&C, x, flags, 0, stdout, 0);
jvp_dtoa_context_free(&C);
+ if (flags & JV_PRINT_UNBUFFERED) {
+ fflush(stdout);
+ }
}
jv jv_dump_string(jv x, int flags) {
COLOUR_OUTPUT = 64,
NO_COLOUR_OUTPUT = 128,
SORTED_OUTPUT = 256,
+ UNBUFFERED_OUTPUT = 4096,
FROM_FILE = 512,
if (options & ASCII_OUTPUT) dumpopts |= JV_PRINT_ASCII;
if (options & COLOUR_OUTPUT) dumpopts |= JV_PRINT_COLOUR;
if (options & NO_COLOUR_OUTPUT) dumpopts &= ~JV_PRINT_COLOUR;
+ if (options & UNBUFFERED_OUTPUT) dumpopts |= JV_PRINT_UNBUFFERED;
jv_dump(result, dumpopts);
}
printf("\n");
options |= NO_COLOUR_OUTPUT;
} else if (isoption(argv[i], 'a', "ascii-output")) {
options |= ASCII_OUTPUT;
+ } else if (isoption(argv[i], 0, "unbuffered")) {
+ options |= UNBUFFERED_OUTPUT;
} else if (isoption(argv[i], 'S', "sort-keys")) {
options |= SORTED_OUTPUT;
} else if (isoption(argv[i], 'R', "raw-input")) {