aboutsummaryrefslogtreecommitdiff
path: root/jsonsaver/saver2v2/save_other_license.go
blob: fc8a6b5141a6600e72c795a86e026f3d1f635f15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later

package saver2v2

import (
	"github.com/spdx/tools-golang/spdx"
)

func renderOtherLicenses2_2(otherlicenses []*spdx.OtherLicense2_2, jsondocument map[string]interface{}) ([]interface{}, error) {

	var licenses []interface{}
	for _, v := range otherlicenses {
		lic := make(map[string]interface{})
		if v.LicenseIdentifier != "" {
			lic["licenseId"] = v.LicenseIdentifier
		}
		if v.ExtractedText != "" {
			lic["extractedText"] = v.ExtractedText
		}
		if v.LicenseComment != "" {
			lic["comment"] = v.LicenseComment
		}
		if v.LicenseName != "" {
			lic["name"] = v.LicenseName
		}
		if v.LicenseCrossReferences != nil {
			lic["seeAlsos"] = v.LicenseCrossReferences
		}
		licenses = append(licenses, lic)
	}
	if len(licenses) > 0 {
		jsondocument["hasExtractedLicensingInfos"] = licenses
	}
	return licenses, nil
}