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

package state

import (
	tinyjson "github.com/CosmWasm/tinyjson"
	jlexer "github.com/CosmWasm/tinyjson/jlexer"
	jwriter "github.com/CosmWasm/tinyjson/jwriter"
)

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

func tinyjsonB8ca2ff2DecodeGithubComArchwayNetworkVoterSrcState(in *jlexer.Lexer, out *IBCStats) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeFieldName(false)
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "voting_id":
			out.VotingID = uint64(in.Uint64())
		case "from":
			out.From = string(in.String())
		case "status":
			out.Status = IBCSendStatus(in.String())
		case "created_at":
			out.CreatedAt = uint64(in.Uint64())
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func tinyjsonB8ca2ff2EncodeGithubComArchwayNetworkVoterSrcState(out *jwriter.Writer, in IBCStats) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"voting_id\":"
		out.RawString(prefix[1:])
		out.Uint64(uint64(in.VotingID))
	}
	{
		const prefix string = ",\"from\":"
		out.RawString(prefix)
		out.String(string(in.From))
	}
	{
		const prefix string = ",\"status\":"
		out.RawString(prefix)
		out.String(string(in.Status))
	}
	{
		const prefix string = ",\"created_at\":"
		out.RawString(prefix)
		out.Uint64(uint64(in.CreatedAt))
	}
	out.RawByte('}')
}

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

// MarshalTinyJSON supports tinyjson.Marshaler interface
func (v IBCStats) MarshalTinyJSON(w *jwriter.Writer) {
	tinyjsonB8ca2ff2EncodeGithubComArchwayNetworkVoterSrcState(w, v)
}

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

// UnmarshalTinyJSON supports tinyjson.Unmarshaler interface
func (v *IBCStats) UnmarshalTinyJSON(l *jlexer.Lexer) {
	tinyjsonB8ca2ff2DecodeGithubComArchwayNetworkVoterSrcState(l, v)
}
