common_easyjson.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
  2. package common
  3. import (
  4. json "encoding/json"
  5. easyjson "github.com/mailru/easyjson"
  6. jlexer "github.com/mailru/easyjson/jlexer"
  7. jwriter "github.com/mailru/easyjson/jwriter"
  8. )
  9. // suppress unused package warning
  10. var (
  11. _ *json.RawMessage
  12. _ *jlexer.Lexer
  13. _ *jwriter.Writer
  14. _ easyjson.Marshaler
  15. )
  16. func easyjsonC803d3e7DecodeCommon(in *jlexer.Lexer, out *World) {
  17. isTopLevel := in.IsStart()
  18. if in.IsNull() {
  19. if isTopLevel {
  20. in.Consumed()
  21. }
  22. in.Skip()
  23. return
  24. }
  25. in.Delim('{')
  26. for !in.IsDelim('}') {
  27. key := in.UnsafeString()
  28. in.WantColon()
  29. if in.IsNull() {
  30. in.Skip()
  31. in.WantComma()
  32. continue
  33. }
  34. switch key {
  35. case "id":
  36. out.Id = int32(in.Int32())
  37. case "randomNumber":
  38. out.RandomNumber = int32(in.Int32())
  39. default:
  40. in.SkipRecursive()
  41. }
  42. in.WantComma()
  43. }
  44. in.Delim('}')
  45. if isTopLevel {
  46. in.Consumed()
  47. }
  48. }
  49. func easyjsonC803d3e7EncodeCommon(out *jwriter.Writer, in World) {
  50. out.RawByte('{')
  51. first := true
  52. _ = first
  53. {
  54. const prefix string = ",\"id\":"
  55. if first {
  56. first = false
  57. out.RawString(prefix[1:])
  58. } else {
  59. out.RawString(prefix)
  60. }
  61. out.Int32(int32(in.Id))
  62. }
  63. {
  64. const prefix string = ",\"randomNumber\":"
  65. if first {
  66. first = false
  67. out.RawString(prefix[1:])
  68. } else {
  69. out.RawString(prefix)
  70. }
  71. out.Int32(int32(in.RandomNumber))
  72. }
  73. out.RawByte('}')
  74. }
  75. // MarshalJSON supports json.Marshaler interface
  76. func (v World) MarshalJSON() ([]byte, error) {
  77. w := jwriter.Writer{}
  78. easyjsonC803d3e7EncodeCommon(&w, v)
  79. return w.Buffer.BuildBytes(), w.Error
  80. }
  81. // MarshalEasyJSON supports easyjson.Marshaler interface
  82. func (v World) MarshalEasyJSON(w *jwriter.Writer) {
  83. easyjsonC803d3e7EncodeCommon(w, v)
  84. }
  85. // UnmarshalJSON supports json.Unmarshaler interface
  86. func (v *World) UnmarshalJSON(data []byte) error {
  87. r := jlexer.Lexer{Data: data}
  88. easyjsonC803d3e7DecodeCommon(&r, v)
  89. return r.Error()
  90. }
  91. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  92. func (v *World) UnmarshalEasyJSON(l *jlexer.Lexer) {
  93. easyjsonC803d3e7DecodeCommon(l, v)
  94. }
  95. func easyjsonC803d3e7DecodeCommon1(in *jlexer.Lexer, out *JSONResponse) {
  96. isTopLevel := in.IsStart()
  97. if in.IsNull() {
  98. if isTopLevel {
  99. in.Consumed()
  100. }
  101. in.Skip()
  102. return
  103. }
  104. in.Delim('{')
  105. for !in.IsDelim('}') {
  106. key := in.UnsafeString()
  107. in.WantColon()
  108. if in.IsNull() {
  109. in.Skip()
  110. in.WantComma()
  111. continue
  112. }
  113. switch key {
  114. case "message":
  115. out.Message = string(in.String())
  116. default:
  117. in.SkipRecursive()
  118. }
  119. in.WantComma()
  120. }
  121. in.Delim('}')
  122. if isTopLevel {
  123. in.Consumed()
  124. }
  125. }
  126. func easyjsonC803d3e7EncodeCommon1(out *jwriter.Writer, in JSONResponse) {
  127. out.RawByte('{')
  128. first := true
  129. _ = first
  130. {
  131. const prefix string = ",\"message\":"
  132. if first {
  133. first = false
  134. out.RawString(prefix[1:])
  135. } else {
  136. out.RawString(prefix)
  137. }
  138. out.String(string(in.Message))
  139. }
  140. out.RawByte('}')
  141. }
  142. // MarshalJSON supports json.Marshaler interface
  143. func (v JSONResponse) MarshalJSON() ([]byte, error) {
  144. w := jwriter.Writer{}
  145. easyjsonC803d3e7EncodeCommon1(&w, v)
  146. return w.Buffer.BuildBytes(), w.Error
  147. }
  148. // MarshalEasyJSON supports easyjson.Marshaler interface
  149. func (v JSONResponse) MarshalEasyJSON(w *jwriter.Writer) {
  150. easyjsonC803d3e7EncodeCommon1(w, v)
  151. }
  152. // UnmarshalJSON supports json.Unmarshaler interface
  153. func (v *JSONResponse) UnmarshalJSON(data []byte) error {
  154. r := jlexer.Lexer{Data: data}
  155. easyjsonC803d3e7DecodeCommon1(&r, v)
  156. return r.Error()
  157. }
  158. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  159. func (v *JSONResponse) UnmarshalEasyJSON(l *jlexer.Lexer) {
  160. easyjsonC803d3e7DecodeCommon1(l, v)
  161. }