🐇 Let’s turn to discussing the JSON output changes. We can add another option to XvcOutputLine
like XvcOutputLine::Json(T: Serializable)
that will output the type with serde_json
. It won’t introduce any other type.
🐢 Yes but what will T
be? Although store structures have serde implementations, they are not useful.
🐇 We can have output types, named like XvcFileListOutput
that will be converted to strings with serialization.
🦊 We do something similar in xvc pipeline export
and import
commands. We use XvcPipelineSchema
and XvcStepSchema
just for import and export commands. We’ll write similar structs for all Json output and will use serde to convert these to strings.
🐢 Unlike import
and export
commands, we have optional fields in the output though. I don’t want content digests to appear in JSON output if they are not required.
🐇 Let’s search for optional fields in Serde.
🦊 There is a crate for optional fields.
🐢 We don’t need another crate for this. Serde has skip_serializing_if
attribute for fields. We can add is_none
as a method to these to skip outputting None fields. All those fields, in this case, will be optional.
🐇 This is fine. We already use structs to format xvc file list
output. We can just use them to output JSON.