spdx / spdx-3-model

The model for the information captured in SPDX version 3 standard.
https://spdx.dev/use/specifications/
Other
70 stars 45 forks source link

Serialization: friendly or unfriendly properties? #55

Open davaya opened 1 year ago

davaya commented 1 year ago

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": "joe@foo.com"},
  {"header_name": "to", "value", "fred@acme.org"}
]

The friendly alternative uses names to directly identify values:

"header": {
  "from": "joe@foo.com",
  "to": "fred@acme.org"
}

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: ?

kestewart commented 1 year ago

This needs to be sorted for 3.0

goneall commented 7 months ago

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