aboutsummaryrefslogtreecommitdiff
path: root/docs/jsonsaver.md
diff options
context:
space:
mode:
authorSteve Winslow <steve@swinslow.net>2022-02-21 17:22:48 -0500
committerGitHub <noreply@github.com>2022-02-21 17:22:48 -0500
commit8c2157410227df4d1d0828690a1c3742a2a41180 (patch)
tree9ecc6d7e5019ae378628746794977d49ccc1c262 /docs/jsonsaver.md
parent9813e3e9ab9528c405c798c153e2da336b37cec9 (diff)
parent1d27f444b396c42e78035e2e26ae3efea17bb0e6 (diff)
downloadspdx-tools-8c2157410227df4d1d0828690a1c3742a2a41180.tar.gz
Merge pull request #104 from spdx/json
Merge JSON saving into main
Diffstat (limited to 'docs/jsonsaver.md')
-rw-r--r--docs/jsonsaver.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/jsonsaver.md b/docs/jsonsaver.md
new file mode 100644
index 0000000..8531cd3
--- /dev/null
+++ b/docs/jsonsaver.md
@@ -0,0 +1,28 @@
+SPDX-License-Identifier: CC-BY-4.0
+
+## Working
+
+The spdx document is converted to map[string]interface{} and then the entire map is converted to json using a single json Marshall function call . The saver uses a tempoarary storage to store all the files (Paackaged and Unpackaged) together in a single data structure in order to comply with the json schema defined by spdx .
+
+spdx.Document2_2 → map[string]interface{} → JSON
+
+## Some Key Points
+
+- The packages have a property "hasFiles" defined in the schema which is an array of the SPDX Identifiers of the files of that pacakge . The saver iterates through the files of a package and inserted all the SPDX Identifiers of the files in the "hasFiles" array . In addition it adds the file to a temporary storage map to store all the files of the entire document at a single place .
+
+- The files require the packages to be saved before them in order to ensure that the packaged files are added to the temporary storage before the files are saved .
+
+- The snippets are saved after the files and a property "snippetFromFile" identifies the file of the snippets.
+
+The json file loader in `package jsonsaver` makes the following assumptions:
+
+
+### Order of appearance of the properties
+* The saver does not make any pre-assumptions based on the order in which the properties are saved .
+
+
+### Annotations
+* The json spdx schema does not define the SPDX Identifier property for the annotation object . The saver inserts the annotation inside the element who spdx identifier mathches the annotation SPDX identifier .
+
+### Indentation
+* The jsonsaver uses the marshall indent function with "" as he prefix and "\t" as the indent character , passed as funtion parameters . \ No newline at end of file