Skip to main content

detect_format

Function detect_format 

Source
pub fn detect_format(value: &Value) -> Result<SbomFormat, ParseError>
Expand description

Identify an SBOM’s format by inspecting top-level JSON keys without full deserialization.

Detection rules (in order):

  1. bomFormat == "CycloneDX" → CycloneDX (case-insensitive per spec).
  2. spdxVersion present → SPDX.
  3. schema.url containing “anchore.io/schema/syft” → Syft.

Returns ParseError::UnknownFormat when none match.