spdx-3-model icon indicating copy to clipboard operation
spdx-3-model copied to clipboard

Serialization: friendly or unfriendly properties?

Open davaya opened this issue 3 years ago • 2 comments

IBM coined the term "unfriendly" for serializations that use repeated constant property names, and "friendly" where property names directly identify the property. For example, an unfriendly email header would be:

"header": [
  {"header_name": "from", "value": "[email protected]"},
  {"header_name": "to", "value", "[email protected]"}
]

The friendly alternative uses names to directly identify values:

"header": {
  "from": "[email protected]",
  "to": "[email protected]"
}

In SPDX this affects the serialization of types such as Hash ("algorithm", "hashValue") and NamespaceMap ("prefix", "namespace"). The logical model is unaffected; this issue concerns only serialization.

The unfriendly serialization of NamespaceMap is:

"namespace": [
  {"prefix": "acme", "namespace": "http://sboms.acme.org"}
]

and the friendly version is:

"namespace": {
  "acme": "http://sboms.acme.org"
}

Proposal: where repeated constant property names appear in lists of the form {"tag": x, "value": y} pairs, serialize them as object properties {x: y}.

Decision: ?

davaya avatar Jan 01 '23 20:01 davaya

This needs to be sorted for 3.0

kestewart avatar May 05 '23 20:05 kestewart

To be considered as part of any simple JSON proposal. Moving to 3.1

goneall avatar Apr 03 '24 21:04 goneall