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:
parent
53c4d07b45
commit
29d69ca2e0
1 changed files with 11 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue