func (e *EventJSONEncoder) Encode(event nuclio.Event) error {
	eventToEncode := eventAsMap(event)
	if bodyObject, isMapStringInterface := event.GetBodyObject().(map[string]interface{}); isMapStringInterface {
		eventToEncode["body"] = bodyObject
	} else {
		eventToEncode["body"] = base64.StdEncoding.EncodeToString(event.GetBody())
	}
	return json.NewEncoder(e.writer).Encode(eventToEncode)
}
Encode writes the JSON encoding of event to the stream, followed by a newline character
package rpc
import (
	"encoding/base64"
	"encoding/json"
	"io"
	"github.com/nuclio/logger"
	"github.com/nuclio/nuclio-sdk-go"
)
type EventJSONEncoder struct {
	logger logger.Logger
	writer io.Writer
}
func NewEventJSONEncoder(logger logger.Logger, writer io.Writer) *EventJSONEncoder {
	return &EventJSONEncoder{logger, writer}
}