lbry.go/claim/decode.go
2019-05-10 14:04:02 +02:00

24 lines
401 B
Go

package claim
import (
"bytes"
types "github.com/lbryio/types/v2/go"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
func ToJSON(value []byte) (string, error) {
c := &types.Claim{}
err := proto.Unmarshal(value, c)
if err != nil {
return "", err
}
b := bytes.NewBuffer(nil)
m := jsonpb.Marshaler{Indent: " "}
err = m.Marshal(b, c)
return b.String(), err
}