2018-11-08 21:52:47 +01:00
|
|
|
package claim
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2019-01-09 19:05:41 +01:00
|
|
|
types "github.com/lbryio/types/go"
|
|
|
|
|
2018-11-08 21:52:47 +01:00
|
|
|
"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
|
|
|
|
}
|