Skip to content

Commit 7545941

Browse files
jeffhostetlergitster
authored andcommitted
json_writer: new routines to create JSON data
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. Helped-by: Eric Sunshine <[email protected]> Helped-by: René Scharfe <[email protected]> Helped-by: Wink Saville <[email protected]> Helped-by: Ramsay Jones <[email protected]> Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b2453d3 commit 7545941

File tree

8 files changed

+1471
-0
lines changed

8 files changed

+1471
-0
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ TEST_BUILTINS_OBJS += test-example-decorate.o
709709
TEST_BUILTINS_OBJS += test-genrandom.o
710710
TEST_BUILTINS_OBJS += test-hashmap.o
711711
TEST_BUILTINS_OBJS += test-index-version.o
712+
TEST_BUILTINS_OBJS += test-json-writer.o
712713
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
713714
TEST_BUILTINS_OBJS += test-match-trees.o
714715
TEST_BUILTINS_OBJS += test-mergesort.o
@@ -871,6 +872,7 @@ LIB_OBJS += hashmap.o
871872
LIB_OBJS += help.o
872873
LIB_OBJS += hex.o
873874
LIB_OBJS += ident.o
875+
LIB_OBJS += json-writer.o
874876
LIB_OBJS += kwset.o
875877
LIB_OBJS += levenshtein.o
876878
LIB_OBJS += line-log.o

0 commit comments

Comments
 (0)