Skip to content

Commit

Permalink
add omitempty for did doc
Browse files Browse the repository at this point in the history
  • Loading branch information
vmidyllic committed May 29, 2023
1 parent e46585e commit 8a26302
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions verifiable/did_doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
type DIDDocument struct {
Context []string `json:"@context"`
ID string `json:"id"`
Service []interface{} `json:"service"`
VerificationMethod []CommonVerificationMethod `json:"verificationMethod"`
Authentication []Authentication `json:"authentication"`
KeyAgreement []interface{} `json:"keyAgreement"`
Service []interface{} `json:"service,omitempty"`
VerificationMethod []CommonVerificationMethod `json:"verificationMethod,omitempty"`
Authentication []Authentication `json:"authentication,omitempty"`
KeyAgreement []interface{} `json:"keyAgreement,omitempty"`
}

// Service describes standard DID document service field.
Expand Down Expand Up @@ -74,6 +74,9 @@ func (a *Authentication) DID() string {
}

func (a *Authentication) UnmarshalJSON(b []byte) error {
if b == nil {
return nil
}
type Alias Authentication
switch b[0] {
case '{':
Expand Down

0 comments on commit 8a26302

Please sign in to comment.