func (c *JSONCodec) Execute(e Endpoint, ctx Context, msg ...Message) ([]Message, error) {
	const op = errors.Op("json_codec_execute")
	if len(msg) == 0 {
		return nil, nil
	}
	var response = make([]jsonFrame, 0, 5)
	var result = make([]Message, 0, 5)
	var err error
	frames := make([]jsonFrame, 0, len(msg))
	for _, m := range msg {
		frame, errF := c.packFrame(m)
		if errF != nil {
			return nil, errors.E(op, errF)
		}
		frames = append(frames, frame)
	}
	p := &payload.Payload{}
	if ctx.IsEmpty() {
		p.Context = []byte("null")
	}
	p.Context, err = json.Marshal(ctx)
	if err != nil {
		return nil, errors.E(op, err)
	}
	p.Body, err = json.Marshal(frames)
	if err != nil {
		return nil, errors.E(op, err)
	}
	if c.level >= DebugNormal {
		logMessage := utils.AsString(p.Body) + " " + utils.AsString(p.Context)
		if c.level >= DebugHumanized {
			logMessage = color.GreenString(logMessage)
		}
		c.logger.Debug(logMessage)
	}
	out, err := e.Exec(p)
	if err != nil {
		return nil, errors.E(op, err)
	}
	if len(out.Body) == 0 {
		return nil, nil
	}
	if c.level >= DebugNormal {
		logMessage := utils.AsString(out.Body)
		if c.level >= DebugHumanized {
			logMessage = color.HiYellowString(logMessage)
		}
		c.logger.Debug(logMessage, "receive", true)
	}
	err = json.Unmarshal(out.Body, &response)
	if err != nil {
		return nil, errors.E(op, err)
	}
	for _, f := range response {
		msg, err := c.parseFrame(f)
		if err != nil {
			return nil, errors.E(op, err)
		}
		result = append(result, msg)
	}
	return result, nil
}
Execute exchanges commands with worker.
package protocol
import (
	"github.com/fatih/color"
	j "github.com/json-iterator/go"
	"github.com/spiral/errors"
	"github.com/spiral/roadrunner-plugins/v2/logger"
	"github.com/spiral/roadrunner/v2/payload"
	"github.com/spiral/roadrunner/v2/utils"
	"go.temporal.io/api/common/v1"
	"go.temporal.io/api/failure/v1"
)
var json = j.ConfigCompatibleWithStandardLibrary
type JSONCodec struct {
	level DebugLevel
	logger logger.Logger
}
type jsonFrame struct {
	ID uint64 `json:"id"`
	Command string `json:"command,omitempty"`
	Options j.RawMessage `json:"options,omitempty"`
	Failure []byte `json:"failure,omitempty"`
	Payloads []byte `json:"payloads,omitempty"`
}
func NewJSONCodec(level DebugLevel, logger logger.Logger) Codec {
	return &JSONCodec{
		level:  level,
		logger: logger,
	}
}
func (c *JSONCodec) WithLogger(logger logger.Logger) Codec {
	return &JSONCodec{
		level:  c.level,
		logger: logger,
	}
}
func (c *JSONCodec) GetName() string {
	return "json"
}