json convenience method

This commit is contained in:
Alex Grintsvayg 2021-04-02 12:57:06 -04:00
parent 419e7c88a3
commit be64130ae1
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5

View file

@ -56,6 +56,15 @@ func (s SDBlob) HashHex() string {
return hex.EncodeToString(s.Hash())
}
// ToJson returns the SD blob hash as JSON
func (s SDBlob) ToJson() string {
j, err := json.MarshalIndent(s, "", " ")
if err != nil {
panic(err)
}
return string(j)
}
// ToBlob converts the SDBlob to a normal data Blob
func (s SDBlob) ToBlob() Blob {
jsonSD, err := json.Marshal(s)