lbry.go/claim/pretty.go
2017-11-20 13:44:19 -05:00

28 lines
580 B
Go

package claim
import (
"encoding/json"
"fmt"
"github.com/golang/protobuf/jsonpb"
)
func marshalToString(c *ClaimHelper) (string, error) {
m_pb := &jsonpb.Marshaler{}
return m_pb.MarshalToString(c)
}
func (c *ClaimHelper) RenderJSON() (string, error) {
r, err := marshalToString(c)
if err != nil {
fmt.Println("err")
return "", err
}
var dat map[string]interface{}
err = json.Unmarshal([]byte(r), &dat)
if err != nil {
return "", err
}
return r, nil
}
//TODO: encode byte arrays with b58 for addresses and b16 for source hashes instead of the default of b64