func (s AppGenesisState) MarshalGenesis(cdc *codec.Codec, key string, val interface{}) error {
	raw, err := cdc.MarshalJSON(val)
	if err != nil {
		return err
	}
	_, ok := s[key]
	if !ok {
		return fmt.Errorf("key no found for %s", key)
	}
	s[key] = raw
	return nil
}
MarshalGenesis marshals the genesis state for a module in app genesis
package types
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"github.com/cosmos/cosmos-sdk/codec"
	sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
	tmos "github.com/tendermint/tendermint/libs/os"
	tmtypes "github.com/tendermint/tendermint/types"
)
type AppGenesisState map[string]json.RawMessage
func (s AppGenesisState) UnmarshalGenesis(cdc *codec.Codec, key string, val interface{}) error {
	raw, ok := s[key]
	if !ok {
		return fmt.Errorf("key no found for %s", key)
	}
	return cdc.UnmarshalJSON(raw, val)
}