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