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

package types

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 tinyjson18e7fdDecodeGithubComArchwayNetworkVoterSrcTypes(in *jlexer.Lexer, out *MsgSudo) {
	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 "change_new_voting_cost":
			if in.IsNull() {
				in.Skip()
				out.ChangeNewVotingCost = nil
			} else {
				if out.ChangeNewVotingCost == nil {
					out.ChangeNewVotingCost = new(ChangeCostRequest)
				}
				(*out.ChangeNewVotingCost).UnmarshalTinyJSON(in)
			}
		case "change_vote_cost":
			if in.IsNull() {
				in.Skip()
				out.ChangeVoteCost = nil
			} else {
				if out.ChangeVoteCost == nil {
					out.ChangeVoteCost = new(ChangeCostRequest)
				}
				(*out.ChangeVoteCost).UnmarshalTinyJSON(in)
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func tinyjson18e7fdEncodeGithubComArchwayNetworkVoterSrcTypes(out *jwriter.Writer, in MsgSudo) {
	out.RawByte('{')
	first := true
	_ = first
	if in.ChangeNewVotingCost != nil {
		const prefix string = ",\"change_new_voting_cost\":"
		first = false
		out.RawString(prefix[1:])
		(*in.ChangeNewVotingCost).MarshalTinyJSON(out)
	}
	if in.ChangeVoteCost != nil {
		const prefix string = ",\"change_vote_cost\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		(*in.ChangeVoteCost).MarshalTinyJSON(out)
	}
	out.RawByte('}')
}

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

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

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

// UnmarshalTinyJSON supports tinyjson.Unmarshaler interface
func (v *MsgSudo) UnmarshalTinyJSON(l *jlexer.Lexer) {
	tinyjson18e7fdDecodeGithubComArchwayNetworkVoterSrcTypes(l, v)
}
func tinyjson18e7fdDecodeGithubComArchwayNetworkVoterSrcTypes1(in *jlexer.Lexer, out *ChangeCostRequest) {
	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 "new_cost":
			(out.NewCost).UnmarshalTinyJSON(in)
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func tinyjson18e7fdEncodeGithubComArchwayNetworkVoterSrcTypes1(out *jwriter.Writer, in ChangeCostRequest) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"new_cost\":"
		out.RawString(prefix[1:])
		(in.NewCost).MarshalTinyJSON(out)
	}
	out.RawByte('}')
}

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

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

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

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