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

Re: Pretty output in JSON format

From
Sean Allred <allred.sean@gmail.com>
Date
Sep 25, 2024, 18:45 UTC
Message-ID
<m0r097mv19.fsf@epic96565.epic.com>
In-Reply-To
<ZvM39VNFptcfwMGk@tapette.crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 7 quoted lines
> On 2024-09-24 at 21:52:35, Ron Ziroby Romero wrote:
>> What do y'all think?
>
> I think this is ultimately a bad idea.  JSON requires that the output be
> UTF-8, but Git processes a large amount of data, including file names,
> ref names, commit messages, author and committer identities, diff
> output, and other file contents, that are not restricted to UTF-8.

This strikes me with a little bit of 'perfect as the enemy of good' here. I'm sure there are ways to signal an encoding failure. I would, however, caution against trying to provide diff output in JSON. That just seems... odd. Maybe base64 it first? (I don't know -- I just struggle to see the use-case here.)

> However, if you were interested in CBOR output, which isn't
> human-readable but is capable of handling byte strings, then I don't
> see a problem. CBOR is used in FIDO2 and a variety of other protocols
> and is interoperable, so it should be a fine choice here.

CBOR would certainly solve the byte stream problem, but I think it would primarily be only useful for 'serious' toolsmiths that need to handle wildly unpredictable data. For most uses, JSON would get the job done.

>> What do y'all think?

As with all things, I'd suggest you draw up a more formal proposal of exactly how this would work, and then that proposal can be discussed. How would you use this option? What would its behavior be? What's in scope? What's _not_ in scope? :-)

-- 
Sean Allred
Previous: brian m. carlsonNext: brian m. carlson
Message 3 of 8 in “Pretty output in JSON format”
  1. Ron Ziroby RomeroSep 24, 2024
  2. brian m. carlsonSep 24, 2024
  3. Sean AllredSep 25, 2024
  4. brian m. carlsonSep 26, 2024
  5. Ron Ziroby RomeroSep 27, 2024
  6. Ron Ziroby RomeroJul 31, 2025
  7. Ron Ziroby RomeroAug 4, 2025
  8. Junio C HamanoAug 4, 2025

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.