Skip to content

Commit

Permalink
Add JSON method to assets.Asset and assets.Key types
Browse files Browse the repository at this point in the history
  • Loading branch information
bandreghetti committed Jun 9, 2021
1 parent f8c713b commit a0720ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,12 @@ func (a Asset) String() string {
}
return string(ret)
}

// JSON returns the Asset in JSON format.
func (a Asset) JSON() []byte {
ret, err := json.Marshal(a)
if err != nil {
return nil
}
return ret
}
9 changes: 9 additions & 0 deletions assets/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,12 @@ func (k Key) String() string {
ret, _ := json.Marshal(k)
return string(ret)
}

// JSON returns the Asset in JSON format.
func (k Key) JSON() []byte {
ret, err := json.Marshal(k)
if err != nil {
return nil
}
return ret
}

0 comments on commit a0720ca

Please sign in to comment.