github.com/antihax/goesi@v0.0.0-20240126031043-6c54d0cb7f95/esi/model_get_status_ok_easyjson.go (about)

     1  // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
     2  
     3  package esi
     4  
     5  import (
     6  	json "encoding/json"
     7  
     8  	easyjson "github.com/mailru/easyjson"
     9  	jlexer "github.com/mailru/easyjson/jlexer"
    10  	jwriter "github.com/mailru/easyjson/jwriter"
    11  )
    12  
    13  // suppress unused package warning
    14  var (
    15  	_ *json.RawMessage
    16  	_ *jlexer.Lexer
    17  	_ *jwriter.Writer
    18  	_ easyjson.Marshaler
    19  )
    20  
    21  func easyjsonCd04e186DecodeGithubComAntihaxGoesiEsi(in *jlexer.Lexer, out *GetStatusOkList) {
    22  	isTopLevel := in.IsStart()
    23  	if in.IsNull() {
    24  		in.Skip()
    25  		*out = nil
    26  	} else {
    27  		in.Delim('[')
    28  		if *out == nil {
    29  			if !in.IsDelim(']') {
    30  				*out = make(GetStatusOkList, 0, 1)
    31  			} else {
    32  				*out = GetStatusOkList{}
    33  			}
    34  		} else {
    35  			*out = (*out)[:0]
    36  		}
    37  		for !in.IsDelim(']') {
    38  			var v1 GetStatusOk
    39  			(v1).UnmarshalEasyJSON(in)
    40  			*out = append(*out, v1)
    41  			in.WantComma()
    42  		}
    43  		in.Delim(']')
    44  	}
    45  	if isTopLevel {
    46  		in.Consumed()
    47  	}
    48  }
    49  func easyjsonCd04e186EncodeGithubComAntihaxGoesiEsi(out *jwriter.Writer, in GetStatusOkList) {
    50  	if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
    51  		out.RawString("null")
    52  	} else {
    53  		out.RawByte('[')
    54  		for v2, v3 := range in {
    55  			if v2 > 0 {
    56  				out.RawByte(',')
    57  			}
    58  			(v3).MarshalEasyJSON(out)
    59  		}
    60  		out.RawByte(']')
    61  	}
    62  }
    63  
    64  // MarshalJSON supports json.Marshaler interface
    65  func (v GetStatusOkList) MarshalJSON() ([]byte, error) {
    66  	w := jwriter.Writer{}
    67  	easyjsonCd04e186EncodeGithubComAntihaxGoesiEsi(&w, v)
    68  	return w.Buffer.BuildBytes(), w.Error
    69  }
    70  
    71  // MarshalEasyJSON supports easyjson.Marshaler interface
    72  func (v GetStatusOkList) MarshalEasyJSON(w *jwriter.Writer) {
    73  	easyjsonCd04e186EncodeGithubComAntihaxGoesiEsi(w, v)
    74  }
    75  
    76  // UnmarshalJSON supports json.Unmarshaler interface
    77  func (v *GetStatusOkList) UnmarshalJSON(data []byte) error {
    78  	r := jlexer.Lexer{Data: data}
    79  	easyjsonCd04e186DecodeGithubComAntihaxGoesiEsi(&r, v)
    80  	return r.Error()
    81  }
    82  
    83  // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
    84  func (v *GetStatusOkList) UnmarshalEasyJSON(l *jlexer.Lexer) {
    85  	easyjsonCd04e186DecodeGithubComAntihaxGoesiEsi(l, v)
    86  }
    87  func easyjsonCd04e186DecodeGithubComAntihaxGoesiEsi1(in *jlexer.Lexer, out *GetStatusOk) {
    88  	isTopLevel := in.IsStart()
    89  	if in.IsNull() {
    90  		if isTopLevel {
    91  			in.Consumed()
    92  		}
    93  		in.Skip()
    94  		return
    95  	}
    96  	in.Delim('{')
    97  	for !in.IsDelim('}') {
    98  		key := in.UnsafeFieldName(false)
    99  		in.WantColon()
   100  		if in.IsNull() {
   101  			in.Skip()
   102  			in.WantComma()
   103  			continue
   104  		}
   105  		switch key {
   106  		case "players":
   107  			out.Players = int32(in.Int32())
   108  		case "server_version":
   109  			out.ServerVersion = string(in.String())
   110  		case "start_time":
   111  			if data := in.Raw(); in.Ok() {
   112  				in.AddError((out.StartTime).UnmarshalJSON(data))
   113  			}
   114  		case "vip":
   115  			out.Vip = bool(in.Bool())
   116  		default:
   117  			in.SkipRecursive()
   118  		}
   119  		in.WantComma()
   120  	}
   121  	in.Delim('}')
   122  	if isTopLevel {
   123  		in.Consumed()
   124  	}
   125  }
   126  func easyjsonCd04e186EncodeGithubComAntihaxGoesiEsi1(out *jwriter.Writer, in GetStatusOk) {
   127  	out.RawByte('{')
   128  	first := true
   129  	_ = first
   130  	if in.Players != 0 {
   131  		const prefix string = ",\"players\":"
   132  		first = false
   133  		out.RawString(prefix[1:])
   134  		out.Int32(int32(in.Players))
   135  	}
   136  	if in.ServerVersion != "" {
   137  		const prefix string = ",\"server_version\":"
   138  		if first {
   139  			first = false
   140  			out.RawString(prefix[1:])
   141  		} else {
   142  			out.RawString(prefix)
   143  		}
   144  		out.String(string(in.ServerVersion))
   145  	}
   146  	if true {
   147  		const prefix string = ",\"start_time\":"
   148  		if first {
   149  			first = false
   150  			out.RawString(prefix[1:])
   151  		} else {
   152  			out.RawString(prefix)
   153  		}
   154  		out.Raw((in.StartTime).MarshalJSON())
   155  	}
   156  	if in.Vip {
   157  		const prefix string = ",\"vip\":"
   158  		if first {
   159  			first = false
   160  			out.RawString(prefix[1:])
   161  		} else {
   162  			out.RawString(prefix)
   163  		}
   164  		out.Bool(bool(in.Vip))
   165  	}
   166  	out.RawByte('}')
   167  }
   168  
   169  // MarshalJSON supports json.Marshaler interface
   170  func (v GetStatusOk) MarshalJSON() ([]byte, error) {
   171  	w := jwriter.Writer{}
   172  	easyjsonCd04e186EncodeGithubComAntihaxGoesiEsi1(&w, v)
   173  	return w.Buffer.BuildBytes(), w.Error
   174  }
   175  
   176  // MarshalEasyJSON supports easyjson.Marshaler interface
   177  func (v GetStatusOk) MarshalEasyJSON(w *jwriter.Writer) {
   178  	easyjsonCd04e186EncodeGithubComAntihaxGoesiEsi1(w, v)
   179  }
   180  
   181  // UnmarshalJSON supports json.Unmarshaler interface
   182  func (v *GetStatusOk) UnmarshalJSON(data []byte) error {
   183  	r := jlexer.Lexer{Data: data}
   184  	easyjsonCd04e186DecodeGithubComAntihaxGoesiEsi1(&r, v)
   185  	return r.Error()
   186  }
   187  
   188  // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
   189  func (v *GetStatusOk) UnmarshalEasyJSON(l *jlexer.Lexer) {
   190  	easyjsonCd04e186DecodeGithubComAntihaxGoesiEsi1(l, v)
   191  }