-
Notifications
You must be signed in to change notification settings - Fork 419
Description
I'd really like to see some usage feedback of the JSON output, to confirm that the current design makes sense for external consumers.
$ DFT_UNSTABLE=yes DFT_DISPLAY=json difft before.js after.js(No-one has complained yet about
DFT_UNSTABLEbeing required, so I'm not sure anyone is actually using this output option right now.)
via #216 (comment)
I was just trying this out and thought I ought drop in with some of the requested feedback.
So, very nice, but the pedant in me wants to note it is actually JSONL (or NDJSON) specifically :)
If I run it through genson-cli I get the following schema (posted more just in case it's useful to others), like this:
DFT_DISPLAY=json DFT_UNSTABLE=yes git -c diff.external=difft diff --cached | genson-cli --ndjson- git command via manual
- JSON schema inference via genson-cli
Click to show JSON schema (not comprehensive!)
{
"$schema": "http://json-schema.org/schema#",
"properties": {
"chunks": {
"type": "array",
"items": {
"type": "array",
"items": {
"properties": {
"rhs": {
"properties": {
"line_number": {
"type": "integer"
},
"changes": {
"type": "array",
"items": {
"properties": {
"start": {
"type": "integer"
},
"end": {
"type": "integer"
},
"content": {
"type": "string"
},
"highlight": {
"type": "string"
}
},
"required": [
"content",
"end",
"highlight",
"start"
],
"type": "object"
}
}
},
"required": [
"changes",
"line_number"
],
"type": "object"
}
},
"required": [
"rhs"
],
"type": "object"
}
}
},
"language": {
"type": "string"
},
"path": {
"type": "string"
},
"status": {
"type": "string"
}
},
"required": [
"language",
"path",
"status"
],
"type": "object"
}The schema for a file with edits and the schema for a file freshly created is completely different, so the chunks field is not required (for files that are newly created).
Feedback from me is this is very useful, and that this is pretty much perfect for my use. Perhaps uptake of the library can be assisted by sharing the expected JSON format (using a JSON schema or example de/ser structs). For what it's worth the branch I'm working on implementing difftastic as a format on can be found here: lmmx/asterism#12