func (m *Message) UnmarshalJSON(buf []byte) error {
	var l []json.RawMessage
	if err := json.Unmarshal(buf, &l); err != nil {
		return errors.Wrap(err, `failed to unmarshal JSON: expected array`)
	}
	var tag string
	if err := json.Unmarshal(l[0], &tag); err != nil {
		return errors.Wrap(err, `failed to unmarshal JSON: expected tag`)
	}
	var t int64
	if err := json.Unmarshal(l[1], &t); err != nil {
		return errors.Wrap(err, `failed to unmarshal JSON: expected timestamp`)
	}
	var r interface{}
	if err := json.Unmarshal(l[2], &r); err != nil {
		return errors.Wrap(err, `failed to unmarshal JSON: expected record`)
	}
	var o interface{}
	if err := json.Unmarshal(l[3], &o); err != nil {
		return errors.Wrap(err, `failed to unmarshal JSON: expected options`)
	}
	*m = Message{
		Tag:    tag,
		Time:   EventTime{Time: time.Unix(t, 0).UTC()},
		Record: r,
		Option: o,
	}
	return nil
}
UnmarshalJSON deserializes from a JSON buffer and populates
a Message struct appropriately
package fluent
import (
	"bytes"
	"encoding/json"
	"strconv"
	"time"
	msgpack "github.com/lestrrat-go/msgpack"
	pdebug "github.com/lestrrat-go/pdebug"
	"github.com/pkg/errors"
)
func makeMessage(tag string, record interface{}, t time.Time, useSubsecond, needReply bool) *Message {
	msg := getMessage()
	msg.Tag = tag
	msg.Time.Time = t
	msg.Record = record
	msg.subsecond = useSubsecond
	if needReply {
		msg.replyCh = make(chan error, 1)
	}
	return msg
}
func (m *Message) clear() {
	if pdebug.Enabled {
		g := pdebug.Marker("Message.clear")
		defer g.End()
	}
	m.Tag = ""
	m.Time = EventTime{}
	m.Record = nil
	m.Option = nil
	if m.replyCh != nil {
		if pdebug.Enabled {
			pdebug.Printf("Closing reply channel")
		}
		close(m.replyCh)
		m.replyCh = nil
	}
}