Since JSON is intended for programmatic consumption, it makes
sense for the default output format to be concise as possible.
For programmer and other uses, it is helpful to keep the pretty
whitespace format; therefore enable it with -p flag.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David Ahern <dsahern@gmail.com>
#include "json_writer.h"
#include "color.h"
+extern int show_pretty;
+
json_writer_t *get_json_writer(void);
/*
int show_details;
int oneline;
int brief;
+int show_pretty;
int json;
int timestamp;
const char *_SL_;
++brief;
} else if (matches(opt, "-json") == 0) {
++json;
+ } else if (matches(opt, "-pretty") == 0) {
+ ++show_pretty;
} else if (matches(opt, "-rcvbuf") == 0) {
unsigned int size;
perror("json object");
exit(1);
}
- jsonw_pretty(_jw, true);
+ if (show_pretty)
+ jsonw_pretty(_jw, true);
jsonw_start_array(_jw);
}
}
int force;
bool use_names;
int json;
+int pretty;
static char *conf_file;
++timestamp_short;
} else if (matches(argv[1], "-json") == 0) {
++json;
+ } else if (matches(argv[1], "-pretty") == 0) {
+ ++pretty;
} else {
fprintf(stderr, "Option \"%s\" is unknown, try \"tc -help\".\n", argv[1]);
return -1;