add function to marshal aud into a string if the array has a len of 1, to comply with rfc

This commit is contained in:
ORZ (Paul Orzel) 2025-06-20 09:39:40 +02:00
parent 53c4d07b45
commit 29d69ca2e0

View file

@ -35,6 +35,17 @@ func (a *Audience) UnmarshalJSON(text []byte) error {
return nil
}
func (a *Audience) MarshalJSON() ([]byte, error) {
len := len(*a)
if len > 1 {
return json.Marshal(*a)
} else if len == 1 {
return json.Marshal((*a)[0])
}
return nil, errors.New("aud is empty")
}
type Display string
func (d *Display) UnmarshalText(text []byte) error {