On this page
The scan command's declared payload: a stable, additive-only document with the summary, per-format groups and extensionless files, checked before it ships.
#internal/jsonout
#internal/jsonout
Package jsonout builds the machine-readable scan document. The document is the scan command's declared payload: the framework carries it as the envelope's payload member under --json and validates it against Schema before writing it. The shape is a consumer contract (R34): field names are stable, values are raw integers, no ANSI codes, and evolution is additive-only.
#Schema
var Schema = strictcli.SchemaObject(Schema is the scan command's declared payload schema (strictcli ยง19.5). It states the same contract R34/R35 states in prose, in the form the framework enforces at emission: a document deviating from it fails the run instead of shipping a wrong shape to a consumer.
Every stat property is optional because --stats selects which ones the group objects carry; only the two identity fields are required of a group. The additive fields "config" (R46) and "no_extension_files" are optional for the same reason they are omitempty on the struct.
#Selection
type Selection map[string]boolSelection reports which stats were selected via --stats. Unselected stats are omitted from group objects.
#Document
type Document structDocument is the scan command's machine payload. The binary's own version is deliberately absent: the envelope carries it as app_version, and one fact belongs in one place.
#Build
func Build(configPath string, res *scan.Result, groups []scan.Group, sel Selection, listNoExt bool) DocumentBuild assembles the document for a scan result. groups must already be sorted per --sort-by/--sort-order. listNoExt controls the presence of the no_extension_files field. configPath is the absolute path of the scan config file in effect; when empty the additive "config" field is omitted entirely (R46).
#groupJSON.MarshalJSON
func (gj groupJSON) MarshalJSON() ([]byte, error)MarshalJSON writes the group fields in the documented, stable order. Unselected stats are omitted; LOC fields are null for binary groups.