mirror of https://github.com/goccy/go-json.git
454 lines
8.4 KiB
Go
454 lines
8.4 KiB
Go
|
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.
|
||
|
|
||
|
package benchmark
|
||
|
|
||
|
import (
|
||
|
json "encoding/json"
|
||
|
easyjson "github.com/mailru/easyjson"
|
||
|
jlexer "github.com/mailru/easyjson/jlexer"
|
||
|
jwriter "github.com/mailru/easyjson/jwriter"
|
||
|
)
|
||
|
|
||
|
// suppress unused package warning
|
||
|
var (
|
||
|
_ *json.RawMessage
|
||
|
_ *jlexer.Lexer
|
||
|
_ *jwriter.Writer
|
||
|
_ easyjson.Marshaler
|
||
|
)
|
||
|
|
||
|
func easyjson8ca7813eDecodeBenchmark(in *jlexer.Lexer, out *MediumPayloadEasyJson) {
|
||
|
isTopLevel := in.IsStart()
|
||
|
if in.IsNull() {
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
in.Skip()
|
||
|
return
|
||
|
}
|
||
|
in.Delim('{')
|
||
|
for !in.IsDelim('}') {
|
||
|
key := in.UnsafeString()
|
||
|
in.WantColon()
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
in.WantComma()
|
||
|
continue
|
||
|
}
|
||
|
switch key {
|
||
|
case "person":
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
out.Person = nil
|
||
|
} else {
|
||
|
if out.Person == nil {
|
||
|
out.Person = new(CBPerson)
|
||
|
}
|
||
|
easyjson8ca7813eDecodeBenchmark1(in, out.Person)
|
||
|
}
|
||
|
case "company":
|
||
|
out.Company = string(in.String())
|
||
|
default:
|
||
|
in.SkipRecursive()
|
||
|
}
|
||
|
in.WantComma()
|
||
|
}
|
||
|
in.Delim('}')
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
}
|
||
|
func easyjson8ca7813eEncodeBenchmark(out *jwriter.Writer, in MediumPayloadEasyJson) {
|
||
|
out.RawByte('{')
|
||
|
first := true
|
||
|
_ = first
|
||
|
{
|
||
|
const prefix string = ",\"person\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
if in.Person == nil {
|
||
|
out.RawString("null")
|
||
|
} else {
|
||
|
easyjson8ca7813eEncodeBenchmark1(out, *in.Person)
|
||
|
}
|
||
|
}
|
||
|
{
|
||
|
const prefix string = ",\"company\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
out.String(string(in.Company))
|
||
|
}
|
||
|
out.RawByte('}')
|
||
|
}
|
||
|
|
||
|
// MarshalJSON supports json.Marshaler interface
|
||
|
func (v MediumPayloadEasyJson) MarshalJSON() ([]byte, error) {
|
||
|
w := jwriter.Writer{}
|
||
|
easyjson8ca7813eEncodeBenchmark(&w, v)
|
||
|
return w.Buffer.BuildBytes(), w.Error
|
||
|
}
|
||
|
|
||
|
// MarshalEasyJSON supports easyjson.Marshaler interface
|
||
|
func (v MediumPayloadEasyJson) MarshalEasyJSON(w *jwriter.Writer) {
|
||
|
easyjson8ca7813eEncodeBenchmark(w, v)
|
||
|
}
|
||
|
|
||
|
// UnmarshalJSON supports json.Unmarshaler interface
|
||
|
func (v *MediumPayloadEasyJson) UnmarshalJSON(data []byte) error {
|
||
|
r := jlexer.Lexer{Data: data}
|
||
|
easyjson8ca7813eDecodeBenchmark(&r, v)
|
||
|
return r.Error()
|
||
|
}
|
||
|
|
||
|
// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
|
||
|
func (v *MediumPayloadEasyJson) UnmarshalEasyJSON(l *jlexer.Lexer) {
|
||
|
easyjson8ca7813eDecodeBenchmark(l, v)
|
||
|
}
|
||
|
func easyjson8ca7813eDecodeBenchmark1(in *jlexer.Lexer, out *CBPerson) {
|
||
|
isTopLevel := in.IsStart()
|
||
|
if in.IsNull() {
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
in.Skip()
|
||
|
return
|
||
|
}
|
||
|
in.Delim('{')
|
||
|
for !in.IsDelim('}') {
|
||
|
key := in.UnsafeString()
|
||
|
in.WantColon()
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
in.WantComma()
|
||
|
continue
|
||
|
}
|
||
|
switch key {
|
||
|
case "name":
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
out.Name = nil
|
||
|
} else {
|
||
|
if out.Name == nil {
|
||
|
out.Name = new(CBName)
|
||
|
}
|
||
|
easyjson8ca7813eDecodeBenchmark2(in, out.Name)
|
||
|
}
|
||
|
case "github":
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
out.Github = nil
|
||
|
} else {
|
||
|
if out.Github == nil {
|
||
|
out.Github = new(CBGithub)
|
||
|
}
|
||
|
easyjson8ca7813eDecodeBenchmark3(in, out.Github)
|
||
|
}
|
||
|
case "Gravatar":
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
out.Gravatar = nil
|
||
|
} else {
|
||
|
if out.Gravatar == nil {
|
||
|
out.Gravatar = new(CBGravatar)
|
||
|
}
|
||
|
easyjson8ca7813eDecodeBenchmark4(in, out.Gravatar)
|
||
|
}
|
||
|
default:
|
||
|
in.SkipRecursive()
|
||
|
}
|
||
|
in.WantComma()
|
||
|
}
|
||
|
in.Delim('}')
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
}
|
||
|
func easyjson8ca7813eEncodeBenchmark1(out *jwriter.Writer, in CBPerson) {
|
||
|
out.RawByte('{')
|
||
|
first := true
|
||
|
_ = first
|
||
|
{
|
||
|
const prefix string = ",\"name\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
if in.Name == nil {
|
||
|
out.RawString("null")
|
||
|
} else {
|
||
|
easyjson8ca7813eEncodeBenchmark2(out, *in.Name)
|
||
|
}
|
||
|
}
|
||
|
{
|
||
|
const prefix string = ",\"github\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
if in.Github == nil {
|
||
|
out.RawString("null")
|
||
|
} else {
|
||
|
easyjson8ca7813eEncodeBenchmark3(out, *in.Github)
|
||
|
}
|
||
|
}
|
||
|
{
|
||
|
const prefix string = ",\"Gravatar\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
if in.Gravatar == nil {
|
||
|
out.RawString("null")
|
||
|
} else {
|
||
|
easyjson8ca7813eEncodeBenchmark4(out, *in.Gravatar)
|
||
|
}
|
||
|
}
|
||
|
out.RawByte('}')
|
||
|
}
|
||
|
func easyjson8ca7813eDecodeBenchmark4(in *jlexer.Lexer, out *CBGravatar) {
|
||
|
isTopLevel := in.IsStart()
|
||
|
if in.IsNull() {
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
in.Skip()
|
||
|
return
|
||
|
}
|
||
|
in.Delim('{')
|
||
|
for !in.IsDelim('}') {
|
||
|
key := in.UnsafeString()
|
||
|
in.WantColon()
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
in.WantComma()
|
||
|
continue
|
||
|
}
|
||
|
switch key {
|
||
|
case "Avatars":
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
out.Avatars = nil
|
||
|
} else {
|
||
|
in.Delim('[')
|
||
|
if out.Avatars == nil {
|
||
|
if !in.IsDelim(']') {
|
||
|
out.Avatars = make(Avatars, 0, 8)
|
||
|
} else {
|
||
|
out.Avatars = Avatars{}
|
||
|
}
|
||
|
} else {
|
||
|
out.Avatars = (out.Avatars)[:0]
|
||
|
}
|
||
|
for !in.IsDelim(']') {
|
||
|
var v1 *CBAvatar
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
v1 = nil
|
||
|
} else {
|
||
|
if v1 == nil {
|
||
|
v1 = new(CBAvatar)
|
||
|
}
|
||
|
easyjson8ca7813eDecodeBenchmark5(in, v1)
|
||
|
}
|
||
|
out.Avatars = append(out.Avatars, v1)
|
||
|
in.WantComma()
|
||
|
}
|
||
|
in.Delim(']')
|
||
|
}
|
||
|
default:
|
||
|
in.SkipRecursive()
|
||
|
}
|
||
|
in.WantComma()
|
||
|
}
|
||
|
in.Delim('}')
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
}
|
||
|
func easyjson8ca7813eEncodeBenchmark4(out *jwriter.Writer, in CBGravatar) {
|
||
|
out.RawByte('{')
|
||
|
first := true
|
||
|
_ = first
|
||
|
{
|
||
|
const prefix string = ",\"Avatars\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
if in.Avatars == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
|
||
|
out.RawString("null")
|
||
|
} else {
|
||
|
out.RawByte('[')
|
||
|
for v2, v3 := range in.Avatars {
|
||
|
if v2 > 0 {
|
||
|
out.RawByte(',')
|
||
|
}
|
||
|
if v3 == nil {
|
||
|
out.RawString("null")
|
||
|
} else {
|
||
|
easyjson8ca7813eEncodeBenchmark5(out, *v3)
|
||
|
}
|
||
|
}
|
||
|
out.RawByte(']')
|
||
|
}
|
||
|
}
|
||
|
out.RawByte('}')
|
||
|
}
|
||
|
func easyjson8ca7813eDecodeBenchmark5(in *jlexer.Lexer, out *CBAvatar) {
|
||
|
isTopLevel := in.IsStart()
|
||
|
if in.IsNull() {
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
in.Skip()
|
||
|
return
|
||
|
}
|
||
|
in.Delim('{')
|
||
|
for !in.IsDelim('}') {
|
||
|
key := in.UnsafeString()
|
||
|
in.WantColon()
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
in.WantComma()
|
||
|
continue
|
||
|
}
|
||
|
switch key {
|
||
|
case "Url":
|
||
|
out.Url = string(in.String())
|
||
|
default:
|
||
|
in.SkipRecursive()
|
||
|
}
|
||
|
in.WantComma()
|
||
|
}
|
||
|
in.Delim('}')
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
}
|
||
|
func easyjson8ca7813eEncodeBenchmark5(out *jwriter.Writer, in CBAvatar) {
|
||
|
out.RawByte('{')
|
||
|
first := true
|
||
|
_ = first
|
||
|
{
|
||
|
const prefix string = ",\"Url\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
out.String(string(in.Url))
|
||
|
}
|
||
|
out.RawByte('}')
|
||
|
}
|
||
|
func easyjson8ca7813eDecodeBenchmark3(in *jlexer.Lexer, out *CBGithub) {
|
||
|
isTopLevel := in.IsStart()
|
||
|
if in.IsNull() {
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
in.Skip()
|
||
|
return
|
||
|
}
|
||
|
in.Delim('{')
|
||
|
for !in.IsDelim('}') {
|
||
|
key := in.UnsafeString()
|
||
|
in.WantColon()
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
in.WantComma()
|
||
|
continue
|
||
|
}
|
||
|
switch key {
|
||
|
case "Followers":
|
||
|
out.Followers = int(in.Int())
|
||
|
default:
|
||
|
in.SkipRecursive()
|
||
|
}
|
||
|
in.WantComma()
|
||
|
}
|
||
|
in.Delim('}')
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
}
|
||
|
func easyjson8ca7813eEncodeBenchmark3(out *jwriter.Writer, in CBGithub) {
|
||
|
out.RawByte('{')
|
||
|
first := true
|
||
|
_ = first
|
||
|
{
|
||
|
const prefix string = ",\"Followers\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
out.Int(int(in.Followers))
|
||
|
}
|
||
|
out.RawByte('}')
|
||
|
}
|
||
|
func easyjson8ca7813eDecodeBenchmark2(in *jlexer.Lexer, out *CBName) {
|
||
|
isTopLevel := in.IsStart()
|
||
|
if in.IsNull() {
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
in.Skip()
|
||
|
return
|
||
|
}
|
||
|
in.Delim('{')
|
||
|
for !in.IsDelim('}') {
|
||
|
key := in.UnsafeString()
|
||
|
in.WantColon()
|
||
|
if in.IsNull() {
|
||
|
in.Skip()
|
||
|
in.WantComma()
|
||
|
continue
|
||
|
}
|
||
|
switch key {
|
||
|
case "fullName":
|
||
|
out.FullName = string(in.String())
|
||
|
default:
|
||
|
in.SkipRecursive()
|
||
|
}
|
||
|
in.WantComma()
|
||
|
}
|
||
|
in.Delim('}')
|
||
|
if isTopLevel {
|
||
|
in.Consumed()
|
||
|
}
|
||
|
}
|
||
|
func easyjson8ca7813eEncodeBenchmark2(out *jwriter.Writer, in CBName) {
|
||
|
out.RawByte('{')
|
||
|
first := true
|
||
|
_ = first
|
||
|
{
|
||
|
const prefix string = ",\"fullName\":"
|
||
|
if first {
|
||
|
first = false
|
||
|
out.RawString(prefix[1:])
|
||
|
} else {
|
||
|
out.RawString(prefix)
|
||
|
}
|
||
|
out.String(string(in.FullName))
|
||
|
}
|
||
|
out.RawByte('}')
|
||
|
}
|