lbry.go/claim/decode.go
2023-10-12 16:02:40 +02:00

24 lines
421 B
Go

package claim
import (
"bytes"
types "github.com/lbryio/types/v2/go"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/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 := protojson.MarshalOptions{Indent: " "}
b, err = m.Marshal(c)
return b.String(), err
}