page_info_easyjson.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
  2. package model
  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 easyjson142f204aDecodeGitBeejayKimCraftApiModel(in *jlexer.Lexer, out *PageInfo) {
  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.UnsafeFieldName(false)
  28. in.WantColon()
  29. if in.IsNull() {
  30. in.Skip()
  31. in.WantComma()
  32. continue
  33. }
  34. switch key {
  35. case "total":
  36. out.Total = int(in.Int())
  37. case "start_cursor":
  38. if in.IsNull() {
  39. in.Skip()
  40. out.StartCursor = nil
  41. } else {
  42. if out.StartCursor == nil {
  43. out.StartCursor = new(string)
  44. }
  45. *out.StartCursor = string(in.String())
  46. }
  47. case "end_cursor":
  48. if in.IsNull() {
  49. in.Skip()
  50. out.EndCursor = nil
  51. } else {
  52. if out.EndCursor == nil {
  53. out.EndCursor = new(string)
  54. }
  55. *out.EndCursor = string(in.String())
  56. }
  57. case "has_next_page":
  58. out.HasNextPage = bool(in.Bool())
  59. case "has_previous_page":
  60. out.HasPreviousPage = bool(in.Bool())
  61. default:
  62. in.SkipRecursive()
  63. }
  64. in.WantComma()
  65. }
  66. in.Delim('}')
  67. if isTopLevel {
  68. in.Consumed()
  69. }
  70. }
  71. func easyjson142f204aEncodeGitBeejayKimCraftApiModel(out *jwriter.Writer, in PageInfo) {
  72. out.RawByte('{')
  73. first := true
  74. _ = first
  75. {
  76. const prefix string = ",\"total\":"
  77. out.RawString(prefix[1:])
  78. out.Int(int(in.Total))
  79. }
  80. if in.StartCursor != nil {
  81. const prefix string = ",\"start_cursor\":"
  82. out.RawString(prefix)
  83. out.String(string(*in.StartCursor))
  84. }
  85. if in.EndCursor != nil {
  86. const prefix string = ",\"end_cursor\":"
  87. out.RawString(prefix)
  88. out.String(string(*in.EndCursor))
  89. }
  90. {
  91. const prefix string = ",\"has_next_page\":"
  92. out.RawString(prefix)
  93. out.Bool(bool(in.HasNextPage))
  94. }
  95. {
  96. const prefix string = ",\"has_previous_page\":"
  97. out.RawString(prefix)
  98. out.Bool(bool(in.HasPreviousPage))
  99. }
  100. out.RawByte('}')
  101. }
  102. // MarshalJSON supports json.Marshaler interface
  103. func (v PageInfo) MarshalJSON() ([]byte, error) {
  104. w := jwriter.Writer{}
  105. easyjson142f204aEncodeGitBeejayKimCraftApiModel(&w, v)
  106. return w.Buffer.BuildBytes(), w.Error
  107. }
  108. // MarshalEasyJSON supports easyjson.Marshaler interface
  109. func (v PageInfo) MarshalEasyJSON(w *jwriter.Writer) {
  110. easyjson142f204aEncodeGitBeejayKimCraftApiModel(w, v)
  111. }
  112. // UnmarshalJSON supports json.Unmarshaler interface
  113. func (v *PageInfo) UnmarshalJSON(data []byte) error {
  114. r := jlexer.Lexer{Data: data}
  115. easyjson142f204aDecodeGitBeejayKimCraftApiModel(&r, v)
  116. return r.Error()
  117. }
  118. // UnmarshalEasyJSON supports easyjson.Unmarshaler interface
  119. func (v *PageInfo) UnmarshalEasyJSON(l *jlexer.Lexer) {
  120. easyjson142f204aDecodeGitBeejayKimCraftApiModel(l, v)
  121. }