func (cp *CommercialPaper) UnmarshalJSON(data []byte) error {
	jcp := jsonCommercialPaper{commercialPaperAlias: (*commercialPaperAlias)(cp)}
	err := json.Unmarshal(data, &jcp)
	if err != nil {
		return err
	}
	cp.state = jcp.State
	return nil
}
UnmarshalJSON special handler for managing JSON marshalling
package commercialpaper
import (
	"encoding/json"
	"fmt"
	ledgerapi "github.com/hyperledger/fabric-chaincode-integration/commercialpaper/ledger-api"
)
type State uint
const (
	ISSUED State = iota + 1
	TRADING
	REDEEMED
)
func (state State) String() string {
	names := []string{"ISSUED", "TRADING", "REDEEMED"}
	if state < ISSUED || state > REDEEMED {
		return "UNKNOWN"
	}
	return names[state-1]
}
func CreateCommercialPaperKey(issuer string, paperNumber string) string {
	return ledgerapi.MakeKey(issuer, paperNumber)
}
type commercialPaperAlias CommercialPaper
type jsonCommercialPaper struct {
	*commercialPaperAlias
	State State  `json:"currentState"`
	Class string `json:"class"`
	Key   string `json:"key"`
}
type CommercialPaper struct {
	PaperNumber      string `json:"paperNumber"`
	Issuer           string `json:"issuer"`
	IssueDateTime    string `json:"issueDateTime"`
	FaceValue        int    `json:"faceValue"`
	MaturityDateTime string `json:"maturityDateTime"`
	Owner            string `json:"owner"`
	state            State  `metadata:"currentState"`
	class            string `metadata:"class"`
	key              string `metadata:"key"`
}