Skip to content

Commit 7b4f769

Browse files
vargenaugoneall
authored andcommitted
Allow .spdx3.json extension when converting from SPDX 2 to SPDX 3
Fixes #278 Untested, please test before merging. Signed-off-by: Marc-Etienne Vargenau <marc-etienne.vargenau@nokia.com>
1 parent 3384727 commit 7b4f769

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ The file formats can optionally be provided as the 3rd and 4th parameter for the
6262

6363
To convert from SPDX 2 to SPDX 3.0.1:
6464

65-
* use the file extension `.jsonld.json` or `.jsonld`;
65+
* use the file extension `.spdx3.json` or `.jsonld.json` or `.jsonld`;
6666
* or add the options for the from and to file types:
6767

6868
java -jar tools-java-2.0.5-jar-with-dependencies.jar Convert hello.spdx hello.spdx.json TAG JSONLD

src/main/java/org/spdx/tools/SpdxToolsHelper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public enum SerFileType {
7070
static Map<String, SerFileType> EXT_TO_FILETYPE;
7171
static {
7272
HashMap<String, SerFileType> temp = new HashMap<>();
73+
temp.put("spdx3.json", SerFileType.JSONLD);
7374
temp.put("jsonld.json", SerFileType.JSONLD);
7475
temp.put("jsonld", SerFileType.JSONLD);
7576
temp.put("json", SerFileType.JSON);
@@ -159,10 +160,14 @@ public static SerFileType fileToFileType(File file)
159160
if (fileName.endsWith("rdf.ttl")) {
160161
ext = "rdf.ttl";
161162
}
162-
}if ("json".equals(ext)) {
163+
}
164+
if ("json".equals(ext)) {
163165
if (fileName.endsWith("jsonld.json")) {
164166
ext = "jsonld.json";
165167
}
168+
if (fileName.endsWith("spdx3.json")) {
169+
ext = "spdx3.json";
170+
}
166171
}
167172
SerFileType retval = EXT_TO_FILETYPE.get(ext);
168173
if (SerFileType.JSON.equals(retval)) {

0 commit comments

Comments
 (0)