git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/2] routines to generate JSON data

From
Ggit@jeffhostetler.com <git@jeffhostetler.com>
Date
Mar 16, 2018, 19:40 UTC
Message-ID
<20180316194057.77513-1-git@jeffhostetler.com>
From: Jeff Hostetler <jeffhost@microsoft.com>

This patch series adds a set of utility routines to compose data in JSON format into a "struct strbuf". The resulting string can then be output by commands wanting to support a JSON output format.

This is a stand alone patch. Nothing currently uses these routines. I'm currently working on a series to log "telemetry" data (as we discussed briefly during Ævar's "Performance Misc" session [1] in Barcelona last week). And I want emit the data in JSON rather than a fixed column/field format. The JSON routines here are independent of that, so it made sense to submit the JSON part by itself.

Back when we added porcelain=v2 format to status, we talked about adding a JSON format. I think the routines in this patch would let us easily do that, if someone were interested. (Extending status is not on my radar right now, however.)

Documentation for the new API is given in json-writer.h at the bottom of the first patch.

I wasn't sure how to unit test the API from a shell script, so I added a helper command that does most of the work in the second patch.

[1] https://public-inbox.org/git/20180313004940.GG61720@google.com/T/
Jeff Hostetler (2):
  json_writer: new routines to create data in JSON format
  json-writer: unit test
 Makefile                    |   2 +
 json-writer.c               | 224 ++++++++++++++++++++++++++++++++++++++++++++
 json-writer.h               | 120 ++++++++++++++++++++++++
 t/helper/test-json-writer.c | 146 +++++++++++++++++++++++++++++
 t/t0019-json-writer.sh      |  10 ++
 5 files changed, 502 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
-- 
2.9.3
Next: git@jeffhostetler.com
Message 1 of 11 in “routines to generate JSON data”
  1. 0/2 routines to generate JSON datagit@jeffhostetler.com, Mar 16, 2018
  2. 2/2 json-writer: unit testgit@jeffhostetler.com, Mar 16, 2018
  3. 1/2 json_writer: new routines to create data in JSON formatgit@jeffhostetler.com, Mar 16, 2018
  4. Jeff KingMar 16, 2018
  5. Ævar Arnfjörð BjarmasonMar 16, 2018
  6. Jeff KingMar 20, 2018
  7. Jacob KellerMar 17, 2018
  8. Jeff HostetlerMar 19, 2018
  9. Jeff HostetlerMar 19, 2018
  10. Jeff KingMar 20, 2018
  11. Jeff HostetlerMar 20, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.