json_writer V10
PATCH v10 1/1 json_writer V10
From: Jeff Hostetler <[email protected]>
Here is V10 of my json-writer patch. I fixed the DEVELOPER=1 warnings that Eric pointed out and refactored the indent_pretty() code as Junio suggested.
Jeff Hostetler (1):
json_writer: new routines to create JSON data
Makefile | 2 + json-writer.c | 414 ++++++++++++++++++++++++++++++++ json-writer.h | 105 ++++++++ t/helper/test-json-writer.c | 565 ++++++++++++++++++++++++++++++++++++++++++++ t/helper/test-tool.c | 1 + t/helper/test-tool.h | 1 + t/t0019-json-writer.sh | 331 ++++++++++++++++++++++++++ t/t0019/parse_json.perl | 52 ++++ 8 files changed, 1471 insertions(+) create mode 100644 json-writer.c create mode 100644 json-writer.h create mode 100644 t/helper/test-json-writer.c create mode 100755 t/t0019-json-writer.sh create mode 100644 t/t0019/parse_json.perl
Signature · 1 line
2.9.3
PATCH v10 1/1 json_writer: new routines to create JSON data
From: Jeff Hostetler <[email protected]>
Add "struct json_writer" and a series of jw_ routines to compose JSON data into a string buffer. The resulting string may then be printed by commands wanting to support a JSON-like output format.
The json_writer is limited to correctly formatting structured data for output. It does not attempt to build an object model of the JSON data.
We say "JSON-like" because we do not enforce the Unicode (usually UTF-8) requirement on string fields. Internally, Git does not necessarily have Unicode/UTF-8 data for most fields, so it is currently unclear the best way to enforce that requirement. For example, on Linux pathnames can contain arbitrary 8-bit character data, so a command like "status" would not know how to encode the reported pathnames. We may want to revisit this (or double encode such strings) in the future.
--- Makefile | 2 + json-writer.c | 414 ++++++++++++++++++++++++++++++++ json-writer.h | 105 ++++++++ t/helper/test-json-writer.c | 565 ++++++++++++++++++++++++++++++++++++++++++++ t/helper/test-tool.c | 1 + t/helper/test-tool.h | 1 + t/t0019-json-writer.sh | 331 ++++++++++++++++++++++++++ t/t0019/parse_json.perl | 52 ++++ 8 files changed, 1471 insertions(+) create mode 100644 json-writer.c create mode 100644 json-writer.h create mode 100644 t/helper/test-json-writer.c create mode 100755 t/t0019-json-writer.sh create mode 100644 t/t0019/parse_json.perl
Makefile +2 -0
@@ -709,6 +709,7 @@ TEST_BUILTINS_OBJS += test-example-decorate.o TEST_BUILTINS_OBJS += test-genrandom.o TEST_BUILTINS_OBJS += test-hashmap.o TEST_BUILTINS_OBJS += test-index-version.o +TEST_BUILTINS_OBJS += test-json-writer.o TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o TEST_BUILTINS_OBJS += test-match-trees.o TEST_BUILTINS_OBJS += test-mergesort.o
@@ -871,6 +872,7 @@ LIB_OBJS += hashmap.o LIB_OBJS += help.o LIB_OBJS += hex.o LIB_OBJS += ident.o +LIB_OBJS += json-writer.o LIB_OBJS += kwset.o LIB_OBJS += levenshtein.o LIB_OBJS += line-log.o
json-writer.c new file +414 -0
414 lines not on this page · raw message
json-writer.h new file +105 -0
105 lines not on this page · raw message
t/helper/test-json-writer.c new file +565 -0
565 lines not on this page · raw message
t/helper/test-tool.c +1 -0
@@ -19,6 +19,7 @@ static struct test_cmd cmds[] = { { "genrandom", cmd__genrandom }, { "hashmap", cmd__hashmap }, { "index-version", cmd__index_version }, + { "json-writer", cmd__json_writer }, { "lazy-init-name-hash", cmd__lazy_init_name_hash }, { "match-trees", cmd__match_trees }, { "mergesort", cmd__mergesort },
t/helper/test-tool.h +1 -0
@@ -13,6 +13,7 @@ int cmd__example_decorate(int argc, const char **argv);int cmd__genrandom (int argc,const char **argv);int cmd__hashmap (int argc,const char **argv);int cmd__index_version (int argc,const char **argv); +int cmd__json_writer (int argc,const char **argv);int cmd__lazy_init_name_hash (int argc,const char **argv);int cmd__match_trees (int argc,const char **argv);int cmd__mergesort (int argc,const char **argv);
t/t0019-json-writer.sh new file +331 -0
331 lines not on this page · raw message
t/t0019/parse_json.perl new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
2.9.3