// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.

package templates

import (
	json "encoding/json"
	easyjson "github.com/mailru/easyjson"
	jlexer "github.com/mailru/easyjson/jlexer"
	jwriter "github.com/mailru/easyjson/jwriter"
)

// suppress unused package warning
var (
	_ *json.RawMessage
	_ *jlexer.Lexer
	_ *jwriter.Writer
	_ easyjson.Marshaler
)

func easyjson2f1218d5DecodeGoStdSrcTemplates(in *jlexer.Lexer, out *Fortune) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeString()
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "id":
			out.ID = int(in.Int())
		case "message":
			out.Message = string(in.String())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjson2f1218d5EncodeGoStdSrcTemplates(out *jwriter.Writer, in Fortune) {
	out.RawByte('{')
	first := true
	_ = first
	if in.ID != 0 {
		const prefix string = ",\"id\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.Int(int(in.ID))
	}
	if in.Message != "" {
		const prefix string = ",\"message\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		out.String(string(in.Message))
	}
	out.RawByte('}')
}

// MarshalJSON supports json.Marshaler interface
func (v Fortune) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjson2f1218d5EncodeGoStdSrcTemplates(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Fortune) MarshalEasyJSON(w *jwriter.Writer) {
	easyjson2f1218d5EncodeGoStdSrcTemplates(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *Fortune) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson2f1218d5DecodeGoStdSrcTemplates(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Fortune) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjson2f1218d5DecodeGoStdSrcTemplates(l, v)
}
