hughsie / python-uswid

A tiny tool for embedding CoSWID tags in EFI binaries
Other
21 stars 6 forks source link

Add .json as possible file format to import and export #19

Closed CodingVoid closed 2 years ago

hughsie commented 2 years ago

Can you attach an example pls.

CodingVoid commented 2 years ago

For an example xml file:

<SoftwareIdentity xml:lang="en-US" tagId="a4eb14a7-43a5-536b-aaf4-4be142b4dc9b" name="coreboot" version="0.1.2" versionScheme="alphanumeric">
    <Meta colloquialVersion="hash-it" product="coreboot" summary="coreboot is a project to develop open source boot firmware for various architectures"></Meta>
    <Entity name="9elements" regid="9elements.com" role="tagCreator softwareCreator"></Entity>
</SoftwareIdentity>

the JSON equivalent would look like this:

{
  "lang": "en-US",
  "tag-id": "a4eb14a7-43a5-536b-aaf4-4be142b4dc9b",
  "tag-version": 0,
  "software-name": "coreboot",
  "software-version": "0.1.2",
  "version-scheme": "alphanumeric",
  "software-meta": [
    {
      "colloquial-version": "hash-it",
      "product": "coreboot",
      "summary": "coreboot is a project to develop open source boot firmware for various architectures"
    }
  ],
  "entity": [
    {
      "entity-name": "9elements",
      "reg-id": "9elements.com",
      "role": [
        "tagCreator",
        "softwareCreator"
      ]
    }
  ]
}

It's more or less a direct conversion from XML to JSON. Special cases are only the XML specific attributes like 'xml:lang' which get's converted to 'lang' in JSON.