func (c *Contents) MarshalJSON() ([]byte, error) {
	encoded := base64.StdEncoding.EncodeToString(c.Blob)
	return json.Marshal(&PlainContents{
		PluginID: c.PluginID,
		StrBlob:  encoded,
	})
}
MarshalJSON serializes a Contents object encoding the binary data in base64
package policy
import (
	"encoding/base64"
	"encoding/json"
	"fmt"
)
func marshalOp(op Operator) (string, error) {
	var str string
	switch op {
	case AND:
		str = "AND"
	case OR:
		str = "OR"
	case NONE:
		str = "NONE"
	default:
		return "", fmt.Errorf("Invalid operator: '%v'. Valid values are AND, OR, NONE", op)
	}
	return str, nil
}
func unmarshalOp(str string) (Operator, error) {
	var op Operator
	switch str {
	case "AND":
		op = AND
	case "OR":
		op = OR
	case "NONE":
		op = NONE
	default:
		return NONE, fmt.Errorf("Invalid operator: '%v'. Valid values are AND, OR, NONE", str)
	}
	return op, nil
}
func (rs *RuleSet) MarshalJSON() ([]byte, error) {
	operator, err := marshalOp(rs.OOperator)
	if err != nil {
		return nil, err
	}
	type Alias *RuleSet
	return json.Marshal(&struct {
		Op    string `json:"op"`
		Rule  *Rule  `json:"rule,omitempty"`
		Left  Alias  `json:"left,omitempty"`
		Right Alias  `json:"right,omitempty"`
	}{
		Op:    operator,
		Rule:  rs.RRule,
		Left:  Alias(rs.LArg),
		Right: Alias(rs.RArg),
	})
}
type PartialRuleSet struct {
	Op    string           `json:"op"`
	Rule  *json.RawMessage `json:"rule"`
	Left  *PartialRuleSet  `json:"left"`
	Right *PartialRuleSet  `json:"right"`
}
func (rs *RuleSet) UnmarshalJSON(data []byte) error {
	raw := &PartialRuleSet{}
	if err := json.Unmarshal(data, raw); err != nil {
		return err
	}
	ruleset, err := unmarshalRuleSet(raw)
	if err == nil {
		*rs = *ruleset
	}
	return err
}
func unmarshalRuleSet(raw *PartialRuleSet) (*RuleSet, error) {
	if raw == nil {
		return nil, nil
	}
	var err error
	var op Operator
	var rule *Rule
	var left, right *RuleSet
	op, err = unmarshalOp(raw.Op)
	if err != nil {
		return nil, err
	}
	if raw.Rule != nil {
		rule = &Rule{}
		if err = json.Unmarshal(*raw.Rule, rule); err != nil {
			return nil, err
		}
	}
	left, err = unmarshalRuleSet(raw.Left)
	if err != nil {
		return nil, err
	}
	right, err = unmarshalRuleSet(raw.Right)
	if err != nil {
		return nil, err
	}
	return &RuleSet{OOperator: op, RRule: rule, LArg: left, RArg: right}, nil
}
type PlainContents struct {
	PluginID string `json:"plugin_id"`
	StrBlob  string `json:"blob"`
}