From be64130ae1afd5325aabfe09c78aa7108ce84d6b Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Fri, 2 Apr 2021 12:57:06 -0400 Subject: [PATCH] json convenience method --- stream/sdBlob.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stream/sdBlob.go b/stream/sdBlob.go index 9186762..f69cc9b 100644 --- a/stream/sdBlob.go +++ b/stream/sdBlob.go @@ -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)