Skip to content

Sort crossRef members in JSON output#244

Merged
goneall merged 4 commits into
spdx:masterfrom
bact:sort-crossref
Jun 29, 2026
Merged

Sort crossRef members in JSON output#244
goneall merged 4 commits into
spdx:masterfrom
bact:sort-crossref

Conversation

@bact

@bact bact commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

In JSON output, sort the crossRef array by order key, from smallest (0) to largest.

If there is no order, push the element to the end of list and sort them by url.

To fix #243

Note

spdx/Spdx-Java-Library#430 is needed to be landed in Spdx-Java-Library, released, and added to pom.xml of LicenseListPublisher first (and update the pom.xml in this PR), in order for this PR to pass CI test.

That PR implements crossRef sorting directly in LicenseJson and sorting of LicenseJsonTOC and ExceptionJsonTOC.

org.spdx.storage.listedlicense.SortableExceptionJsonTOC is now unused anywhere in the codebase, but kept as it is a public class.

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@goneall

goneall commented Jun 26, 2026

Copy link
Copy Markdown
Member

Suggest adding this to the LicenseJson.java file - that would benefit anyone serializing a license which would include the LicenseListPublisher. It would also simplify the implementation.

Another suggestion - to make the list order deterministic, you could sort on a field in the CrossRef (e.g. the URL string) if there is no order.

@bact

bact commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Thank you. Will move this to Spdx-Java-Library as suggested.

@bact

bact commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

The crossRef sorting part in LicenseJson is now ready for review spdx/Spdx-Java-Library#430

bact added 2 commits June 27, 2026 11:35
SortableExceptionJsonTOC is now unused

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact bact marked this pull request as ready for review June 29, 2026 09:54
@bact

bact commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

java-spdx-library 2.0.4 (with the JSON sorting method) is released and updated to the pom.xml. Test now passed.

@goneall goneall merged commit f595111 into spdx:master Jun 29, 2026
1 check passed
@bact bact deleted the sort-crossref branch June 29, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More stable JSON: Sort crossRef array

2 participants