http_utils_easyjson.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
  2. package utils
  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 easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils(in *jlexer.Lexer, out *ResHead) {
  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 "errcode":
  36. out.ErrCode = int(in.Int())
  37. case "errmsg":
  38. out.ErrMsg = string(in.String())
  39. default:
  40. in.SkipRecursive()
  41. }
  42. in.WantComma()
  43. }
  44. in.Delim('}')
  45. if isTopLevel {
  46. in.Consumed()
  47. }
  48. }
  49. func easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils(out *jwriter.Writer, in ResHead) {
  50. out.RawByte('{')
  51. first := true
  52. _ = first
  53. {
  54. const prefix string = ",\"errcode\":"
  55. out.RawString(prefix[1:])
  56. out.Int(int(in.ErrCode))
  57. }
  58. if in.ErrMsg != "" {
  59. const prefix string = ",\"errmsg\":"
  60. out.RawString(prefix)
  61. out.String(string(in.ErrMsg))
  62. }
  63. out.RawByte('}')
  64. }
  65. // MarshalJSON supports json.Marshaler interface
  66. func (v ResHead) MarshalJSON() ([]byte, error) {
  67. w := jwriter.Writer{}
  68. easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils(&w, v)
  69. return w.Buffer.BuildBytes(), w.Error
  70. }
  71. // MarshalEasyJSON supports easyjson.Marshaler interface
  72. func (v ResHead) MarshalEasyJSON(w *jwriter.Writer) {
  73. easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils(w, v)
  74. }
  75. // UnmarshalJSON supports json.Unmarshaler interface
  76. func (v *ResHead) UnmarshalJSON(data []byte) error {
  77. r := jlexer.Lexer{Data: data}
  78. easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils(&r, v)
  79. return r.Error()
  80. }
  81. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  82. func (v *ResHead) UnmarshalEasyJSON(l *jlexer.Lexer) {
  83. easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils(l, v)
  84. }
  85. func easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils1(in *jlexer.Lexer, out *Res) {
  86. isTopLevel := in.IsStart()
  87. if in.IsNull() {
  88. if isTopLevel {
  89. in.Consumed()
  90. }
  91. in.Skip()
  92. return
  93. }
  94. in.Delim('{')
  95. for !in.IsDelim('}') {
  96. key := in.UnsafeString()
  97. in.WantColon()
  98. if in.IsNull() {
  99. in.Skip()
  100. in.WantComma()
  101. continue
  102. }
  103. switch key {
  104. case "head":
  105. (out.Head).UnmarshalEasyJSON(in)
  106. case "data":
  107. if m, ok := out.Data.(easyjson.Unmarshaler); ok {
  108. m.UnmarshalEasyJSON(in)
  109. } else if m, ok := out.Data.(json.Unmarshaler); ok {
  110. _ = m.UnmarshalJSON(in.Raw())
  111. } else {
  112. out.Data = in.Interface()
  113. }
  114. default:
  115. in.SkipRecursive()
  116. }
  117. in.WantComma()
  118. }
  119. in.Delim('}')
  120. if isTopLevel {
  121. in.Consumed()
  122. }
  123. }
  124. func easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils1(out *jwriter.Writer, in Res) {
  125. out.RawByte('{')
  126. first := true
  127. _ = first
  128. {
  129. const prefix string = ",\"head\":"
  130. out.RawString(prefix[1:])
  131. (in.Head).MarshalEasyJSON(out)
  132. }
  133. if in.Data != nil {
  134. const prefix string = ",\"data\":"
  135. out.RawString(prefix)
  136. if m, ok := in.Data.(easyjson.Marshaler); ok {
  137. m.MarshalEasyJSON(out)
  138. } else if m, ok := in.Data.(json.Marshaler); ok {
  139. out.Raw(m.MarshalJSON())
  140. } else {
  141. out.Raw(json.Marshal(in.Data))
  142. }
  143. }
  144. out.RawByte('}')
  145. }
  146. // MarshalJSON supports json.Marshaler interface
  147. func (v Res) MarshalJSON() ([]byte, error) {
  148. w := jwriter.Writer{}
  149. easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils1(&w, v)
  150. return w.Buffer.BuildBytes(), w.Error
  151. }
  152. // MarshalEasyJSON supports easyjson.Marshaler interface
  153. func (v Res) MarshalEasyJSON(w *jwriter.Writer) {
  154. easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils1(w, v)
  155. }
  156. // UnmarshalJSON supports json.Unmarshaler interface
  157. func (v *Res) UnmarshalJSON(data []byte) error {
  158. r := jlexer.Lexer{Data: data}
  159. easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils1(&r, v)
  160. return r.Error()
  161. }
  162. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  163. func (v *Res) UnmarshalEasyJSON(l *jlexer.Lexer) {
  164. easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils1(l, v)
  165. }
  166. func easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils2(in *jlexer.Lexer, out *RequestPromise) {
  167. isTopLevel := in.IsStart()
  168. if in.IsNull() {
  169. if isTopLevel {
  170. in.Consumed()
  171. }
  172. in.Skip()
  173. return
  174. }
  175. in.Delim('{')
  176. for !in.IsDelim('}') {
  177. key := in.UnsafeString()
  178. in.WantColon()
  179. if in.IsNull() {
  180. in.Skip()
  181. in.WantComma()
  182. continue
  183. }
  184. switch key {
  185. default:
  186. in.SkipRecursive()
  187. }
  188. in.WantComma()
  189. }
  190. in.Delim('}')
  191. if isTopLevel {
  192. in.Consumed()
  193. }
  194. }
  195. func easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils2(out *jwriter.Writer, in RequestPromise) {
  196. out.RawByte('{')
  197. first := true
  198. _ = first
  199. out.RawByte('}')
  200. }
  201. // MarshalJSON supports json.Marshaler interface
  202. func (v RequestPromise) MarshalJSON() ([]byte, error) {
  203. w := jwriter.Writer{}
  204. easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils2(&w, v)
  205. return w.Buffer.BuildBytes(), w.Error
  206. }
  207. // MarshalEasyJSON supports easyjson.Marshaler interface
  208. func (v RequestPromise) MarshalEasyJSON(w *jwriter.Writer) {
  209. easyjsonD579c6ceEncodeGitAionnectComAionnectGoCommonUtils2(w, v)
  210. }
  211. // UnmarshalJSON supports json.Unmarshaler interface
  212. func (v *RequestPromise) UnmarshalJSON(data []byte) error {
  213. r := jlexer.Lexer{Data: data}
  214. easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils2(&r, v)
  215. return r.Error()
  216. }
  217. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  218. func (v *RequestPromise) UnmarshalEasyJSON(l *jlexer.Lexer) {
  219. easyjsonD579c6ceDecodeGitAionnectComAionnectGoCommonUtils2(l, v)
  220. }