github.com/antihax/goesi@v0.0.0-20240126031043-6c54d0cb7f95/esi/model_get_killmails_killmail_id_killmail_hash_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 easyjson79bc02b5DecodeGithubComAntihaxGoesiEsi(in *jlexer.Lexer, out *GetKillmailsKillmailIdKillmailHashOkList) {
    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(GetKillmailsKillmailIdKillmailHashOkList, 0, 0)
    31  			} else {
    32  				*out = GetKillmailsKillmailIdKillmailHashOkList{}
    33  			}
    34  		} else {
    35  			*out = (*out)[:0]
    36  		}
    37  		for !in.IsDelim(']') {
    38  			var v1 GetKillmailsKillmailIdKillmailHashOk
    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 easyjson79bc02b5EncodeGithubComAntihaxGoesiEsi(out *jwriter.Writer, in GetKillmailsKillmailIdKillmailHashOkList) {
    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 GetKillmailsKillmailIdKillmailHashOkList) MarshalJSON() ([]byte, error) {
    66  	w := jwriter.Writer{}
    67  	easyjson79bc02b5EncodeGithubComAntihaxGoesiEsi(&w, v)
    68  	return w.Buffer.BuildBytes(), w.Error
    69  }
    70  
    71  // MarshalEasyJSON supports easyjson.Marshaler interface
    72  func (v GetKillmailsKillmailIdKillmailHashOkList) MarshalEasyJSON(w *jwriter.Writer) {
    73  	easyjson79bc02b5EncodeGithubComAntihaxGoesiEsi(w, v)
    74  }
    75  
    76  // UnmarshalJSON supports json.Unmarshaler interface
    77  func (v *GetKillmailsKillmailIdKillmailHashOkList) UnmarshalJSON(data []byte) error {
    78  	r := jlexer.Lexer{Data: data}
    79  	easyjson79bc02b5DecodeGithubComAntihaxGoesiEsi(&r, v)
    80  	return r.Error()
    81  }
    82  
    83  // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
    84  func (v *GetKillmailsKillmailIdKillmailHashOkList) UnmarshalEasyJSON(l *jlexer.Lexer) {
    85  	easyjson79bc02b5DecodeGithubComAntihaxGoesiEsi(l, v)
    86  }
    87  func easyjson79bc02b5DecodeGithubComAntihaxGoesiEsi1(in *jlexer.Lexer, out *GetKillmailsKillmailIdKillmailHashOk) {
    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 "attackers":
   107  			if in.IsNull() {
   108  				in.Skip()
   109  				out.Attackers = nil
   110  			} else {
   111  				in.Delim('[')
   112  				if out.Attackers == nil {
   113  					if !in.IsDelim(']') {
   114  						out.Attackers = make([]GetKillmailsKillmailIdKillmailHashAttacker, 0, 1)
   115  					} else {
   116  						out.Attackers = []GetKillmailsKillmailIdKillmailHashAttacker{}
   117  					}
   118  				} else {
   119  					out.Attackers = (out.Attackers)[:0]
   120  				}
   121  				for !in.IsDelim(']') {
   122  					var v4 GetKillmailsKillmailIdKillmailHashAttacker
   123  					(v4).UnmarshalEasyJSON(in)
   124  					out.Attackers = append(out.Attackers, v4)
   125  					in.WantComma()
   126  				}
   127  				in.Delim(']')
   128  			}
   129  		case "killmail_id":
   130  			out.KillmailId = int32(in.Int32())
   131  		case "killmail_time":
   132  			if data := in.Raw(); in.Ok() {
   133  				in.AddError((out.KillmailTime).UnmarshalJSON(data))
   134  			}
   135  		case "moon_id":
   136  			out.MoonId = int32(in.Int32())
   137  		case "solar_system_id":
   138  			out.SolarSystemId = int32(in.Int32())
   139  		case "victim":
   140  			(out.Victim).UnmarshalEasyJSON(in)
   141  		case "war_id":
   142  			out.WarId = int32(in.Int32())
   143  		default:
   144  			in.SkipRecursive()
   145  		}
   146  		in.WantComma()
   147  	}
   148  	in.Delim('}')
   149  	if isTopLevel {
   150  		in.Consumed()
   151  	}
   152  }
   153  func easyjson79bc02b5EncodeGithubComAntihaxGoesiEsi1(out *jwriter.Writer, in GetKillmailsKillmailIdKillmailHashOk) {
   154  	out.RawByte('{')
   155  	first := true
   156  	_ = first
   157  	if len(in.Attackers) != 0 {
   158  		const prefix string = ",\"attackers\":"
   159  		first = false
   160  		out.RawString(prefix[1:])
   161  		{
   162  			out.RawByte('[')
   163  			for v5, v6 := range in.Attackers {
   164  				if v5 > 0 {
   165  					out.RawByte(',')
   166  				}
   167  				(v6).MarshalEasyJSON(out)
   168  			}
   169  			out.RawByte(']')
   170  		}
   171  	}
   172  	if in.KillmailId != 0 {
   173  		const prefix string = ",\"killmail_id\":"
   174  		if first {
   175  			first = false
   176  			out.RawString(prefix[1:])
   177  		} else {
   178  			out.RawString(prefix)
   179  		}
   180  		out.Int32(int32(in.KillmailId))
   181  	}
   182  	if true {
   183  		const prefix string = ",\"killmail_time\":"
   184  		if first {
   185  			first = false
   186  			out.RawString(prefix[1:])
   187  		} else {
   188  			out.RawString(prefix)
   189  		}
   190  		out.Raw((in.KillmailTime).MarshalJSON())
   191  	}
   192  	if in.MoonId != 0 {
   193  		const prefix string = ",\"moon_id\":"
   194  		if first {
   195  			first = false
   196  			out.RawString(prefix[1:])
   197  		} else {
   198  			out.RawString(prefix)
   199  		}
   200  		out.Int32(int32(in.MoonId))
   201  	}
   202  	if in.SolarSystemId != 0 {
   203  		const prefix string = ",\"solar_system_id\":"
   204  		if first {
   205  			first = false
   206  			out.RawString(prefix[1:])
   207  		} else {
   208  			out.RawString(prefix)
   209  		}
   210  		out.Int32(int32(in.SolarSystemId))
   211  	}
   212  	if true {
   213  		const prefix string = ",\"victim\":"
   214  		if first {
   215  			first = false
   216  			out.RawString(prefix[1:])
   217  		} else {
   218  			out.RawString(prefix)
   219  		}
   220  		(in.Victim).MarshalEasyJSON(out)
   221  	}
   222  	if in.WarId != 0 {
   223  		const prefix string = ",\"war_id\":"
   224  		if first {
   225  			first = false
   226  			out.RawString(prefix[1:])
   227  		} else {
   228  			out.RawString(prefix)
   229  		}
   230  		out.Int32(int32(in.WarId))
   231  	}
   232  	out.RawByte('}')
   233  }
   234  
   235  // MarshalJSON supports json.Marshaler interface
   236  func (v GetKillmailsKillmailIdKillmailHashOk) MarshalJSON() ([]byte, error) {
   237  	w := jwriter.Writer{}
   238  	easyjson79bc02b5EncodeGithubComAntihaxGoesiEsi1(&w, v)
   239  	return w.Buffer.BuildBytes(), w.Error
   240  }
   241  
   242  // MarshalEasyJSON supports easyjson.Marshaler interface
   243  func (v GetKillmailsKillmailIdKillmailHashOk) MarshalEasyJSON(w *jwriter.Writer) {
   244  	easyjson79bc02b5EncodeGithubComAntihaxGoesiEsi1(w, v)
   245  }
   246  
   247  // UnmarshalJSON supports json.Unmarshaler interface
   248  func (v *GetKillmailsKillmailIdKillmailHashOk) UnmarshalJSON(data []byte) error {
   249  	r := jlexer.Lexer{Data: data}
   250  	easyjson79bc02b5DecodeGithubComAntihaxGoesiEsi1(&r, v)
   251  	return r.Error()
   252  }
   253  
   254  // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
   255  func (v *GetKillmailsKillmailIdKillmailHashOk) UnmarshalEasyJSON(l *jlexer.Lexer) {
   256  	easyjson79bc02b5DecodeGithubComAntihaxGoesiEsi1(l, v)
   257  }