Closed MarkTiedemann closed 1 year ago
Is the question about using identifiers as described in Annex E to identify the license of a file with JSON data?
If yes, adding an extra key-value pair seems easy enough:
"SPDX-License-Identifier": "MIT"
Maybe I'm misunderstanding something....
I think they're asking about annotating the license of the JSON file itself.
Yes, I want to license a JSON file.
https://spdx.dev/ids/ says to add a comment, such as, // SPDX-License-Identifier: MIT
to the respective file, but JSON doesn't have comments.
I guess you could say that this issue is not specific to JSON files but about all files and formats that do not have or allow comments.
There seems to be no other way to embed the license ID within the file. Is this correct? If so, I guess I will have to provide the license out-of-band.
It's external guidance to SPDX (and I won't endorse it or opine on usability here), but the REUSE Software initiative recommends using a separate out-of-band file to denote this where comments can't be used:
If a file is not a plain text file or does not permit the inclusion of comments, the comment header that declares the file’s Copyright and Licensing Information SHOULD be in an adjacent file of the same name with the additional extension .license (example: cat.jpg.license if the original file is cat.jpg).
My comment above about adding a new key-value pair adds the license in-band.
Taking a small example from https://json.org/example.html, instead of
{"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
you have
{"SPDX-License-Identifier": "MIT",
"menu": {
"id": "file",
"value": "File",
"popup": {
"menuitem": [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
So, JSON does not allow comments, but it allows new key-value pairs. This obviously cannot be used in the case you follow a restrictive schema that does not allow you to add new keys.
The schema is restrictive plus, at the root of the JSON file, there's an array, not a an object, so I cannot add a new key-value pair.
The out-of-band solution with a .license
file seems to fit best. Too bad it's not official guidance.
Thank you all for the input and suggestions!
Any advice on how to do this since JSON doesn't have comments?