@@ -62,7 +62,28 @@ type PackageMetadata struct {
6262 Author User `json:"author"`
6363 ReadmeFilename string `json:"readmeFilename,omitempty"`
6464 Users map [string ]bool `json:"users,omitempty"`
65- License string `json:"license,omitempty"`
65+ License License `json:"license,omitempty"`
66+ }
67+
68+ type License string
69+
70+ func (l * License ) UnmarshalJSON (data []byte ) error {
71+ switch data [0 ] {
72+ case '"' :
73+ var value string
74+ if err := json .Unmarshal (data , & value ); err != nil {
75+ return err
76+ }
77+ * l = License (value )
78+ case '{' :
79+ var values map [string ]any
80+ if err := json .Unmarshal (data , & values ); err != nil {
81+ return err
82+ }
83+ value := values ["type" ].(string )
84+ * l = License (value )
85+ }
86+ return nil
6687}
6788
6889// PackageMetadataVersion documentation: https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#version
@@ -74,7 +95,7 @@ type PackageMetadataVersion struct {
7495 Description string `json:"description"`
7596 Author User `json:"author"`
7697 Homepage string `json:"homepage,omitempty"`
77- License string `json:"license,omitempty"`
98+ License License `json:"license,omitempty"`
7899 Repository Repository `json:"repository"`
79100 Keywords []string `json:"keywords,omitempty"`
80101 Dependencies map [string ]string `json:"dependencies,omitempty"`
0 commit comments