]> git.ipfire.org Git - thirdparty/git.git/commit
json_writer: new routines to create JSON data
authorJeff Hostetler <jeffhost@microsoft.com>
Fri, 13 Jul 2018 16:54:08 +0000 (16:54 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Jul 2018 20:55:39 +0000 (13:55 -0700)
commit75459410edd8d3bf38a2f1ad785f54b97770b324
tree2b5d0ed8135d0e2649ebf26f577f26030fb185af
parentb2453d34496cb62b9c63c7a7c9b4bead2431f715
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 <sunshine@sunshineco.com>
Helped-by: René Scharfe <l.s.r@web.de>
Helped-by: Wink Saville <wink@saville.com>
Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
json-writer.c [new file with mode: 0644]
json-writer.h [new file with mode: 0644]
t/helper/test-json-writer.c [new file with mode: 0644]
t/helper/test-tool.c
t/helper/test-tool.h
t/t0019-json-writer.sh [new file with mode: 0755]
t/t0019/parse_json.perl [new file with mode: 0644]