Add benchmark target

This commit is contained in:
Masaaki Goshima 2021-04-19 01:37:03 +09:00
parent 75a8c1e3f5
commit c4835c6cd2
6 changed files with 675 additions and 0 deletions

View File

@ -67,6 +67,18 @@ Replace import statement from `encoding/json` to `github.com/goccy/go-json`
- `json-iterator/go` isn't compatible with `encoding/json` in many ways, but it hasn't been supported for a long time.
## Other libraries
- [jingo](https://github.com/bet365/jingo)
I tried the benchmark but it didn't work.
Also, it seems to panic when it receives an unexpected value because there is no error handling...
- [ffjson](https://github.com/pquerna/ffjson)
Benchmarking gave very slow results.
It seems that it is assumed that the user will use the buffa pool properly.
Also, development seems to have already stopped
# Benchmarks

View File

@ -8,6 +8,7 @@ import (
gojay "github.com/francoispqt/gojay"
gojson "github.com/goccy/go-json"
jsoniter "github.com/json-iterator/go"
"github.com/pquerna/ffjson/ffjson"
segmentiojson "github.com/segmentio/encoding/json"
"github.com/wI2L/jettison"
)
@ -21,6 +22,15 @@ func Benchmark_Encode_SmallStruct_EncodingJson(b *testing.B) {
}
}
func Benchmark_Encode_SmallStruct_FFJson(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := ffjson.Marshal(NewSmallPayloadFFJson()); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Encode_SmallStruct_JsonIter(b *testing.B) {
var json = jsoniter.ConfigCompatibleWithStandardLibrary
b.ReportAllocs()
@ -105,6 +115,16 @@ func Benchmark_Encode_SmallStructCached_EncodingJson(b *testing.B) {
}
}
func Benchmark_Encode_SmallStructCached_FFJson(b *testing.B) {
cached := NewSmallPayloadFFJson()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := ffjson.Marshal(cached); err != nil {
b.Fatal(err)
}
}
}
func Benchmark_Encode_SmallStructCached_JsonIter(b *testing.B) {
var json = jsoniter.ConfigCompatibleWithStandardLibrary
cached := NewSmallPayload()

View File

@ -7,6 +7,7 @@ require (
github.com/goccy/go-json v0.0.0-00010101000000-000000000000
github.com/json-iterator/go v1.1.9
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7
github.com/segmentio/encoding v0.2.4
github.com/valyala/fastjson v1.6.3
github.com/wI2L/jettison v0.7.1

View File

@ -55,6 +55,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe h1:W/GaMY0y69G4cFlmsC6B9sbuo2fP8OFP1ABjt4kPz+w=
@ -69,11 +70,14 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 h1:xoIK0ctDddBMnc74udxJYBqlo9Ylnsp1waqjLsnef20=
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M=
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
@ -111,6 +115,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc=
@ -176,10 +181,12 @@ google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9M
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -4,6 +4,7 @@ import "github.com/francoispqt/gojay"
var SmallFixture = []byte(`{"st": 1,"sid": 486,"tt": "active","gr": 0,"uuid": "de305d54-75b4-431b-adb2-eb6b9e546014","ip": "127.0.0.1","ua": "user_agent","tz": -6,"v": 1}`)
// ffjson:skip
type SmallPayload struct {
St int
Sid int
@ -16,6 +17,18 @@ type SmallPayload struct {
V int
}
type SmallPayloadFFJson struct {
St int
Sid int
Tt string
Gr int
Uuid string
Ip string
Ua string
Tz int
V int
}
//easyjson:json
type SmallPayloadEasyJson struct {
St int
@ -100,3 +113,17 @@ func NewSmallPayloadEasyJson() *SmallPayloadEasyJson {
V: 6,
}
}
func NewSmallPayloadFFJson() *SmallPayloadFFJson {
return &SmallPayloadFFJson{
St: 1,
Sid: 2,
Tt: "TestString",
Gr: 4,
Uuid: "8f9a65eb-4807-4d57-b6e0-bda5d62f1429",
Ip: "127.0.0.1",
Ua: "Mozilla",
Tz: 8,
V: 6,
}
}

View File

@ -0,0 +1,608 @@
// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT.
// source: small_payload.go
package benchmark
import (
"bytes"
"fmt"
fflib "github.com/pquerna/ffjson/fflib/v1"
)
// MarshalJSON marshal bytes to json - template
func (j *SmallPayloadFFJson) MarshalJSON() ([]byte, error) {
var buf fflib.Buffer
if j == nil {
buf.WriteString("null")
return buf.Bytes(), nil
}
err := j.MarshalJSONBuf(&buf)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// MarshalJSONBuf marshal buff to json - template
func (j *SmallPayloadFFJson) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if j == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"St":`)
fflib.FormatBits2(buf, uint64(j.St), 10, j.St < 0)
buf.WriteString(`,"Sid":`)
fflib.FormatBits2(buf, uint64(j.Sid), 10, j.Sid < 0)
buf.WriteString(`,"Tt":`)
fflib.WriteJsonString(buf, string(j.Tt))
buf.WriteString(`,"Gr":`)
fflib.FormatBits2(buf, uint64(j.Gr), 10, j.Gr < 0)
buf.WriteString(`,"Uuid":`)
fflib.WriteJsonString(buf, string(j.Uuid))
buf.WriteString(`,"Ip":`)
fflib.WriteJsonString(buf, string(j.Ip))
buf.WriteString(`,"Ua":`)
fflib.WriteJsonString(buf, string(j.Ua))
buf.WriteString(`,"Tz":`)
fflib.FormatBits2(buf, uint64(j.Tz), 10, j.Tz < 0)
buf.WriteString(`,"V":`)
fflib.FormatBits2(buf, uint64(j.V), 10, j.V < 0)
buf.WriteByte('}')
return nil
}
const (
ffjtSmallPayloadFFJsonbase = iota
ffjtSmallPayloadFFJsonnosuchkey
ffjtSmallPayloadFFJsonSt
ffjtSmallPayloadFFJsonSid
ffjtSmallPayloadFFJsonTt
ffjtSmallPayloadFFJsonGr
ffjtSmallPayloadFFJsonUuid
ffjtSmallPayloadFFJsonIp
ffjtSmallPayloadFFJsonUa
ffjtSmallPayloadFFJsonTz
ffjtSmallPayloadFFJsonV
)
var ffjKeySmallPayloadFFJsonSt = []byte("St")
var ffjKeySmallPayloadFFJsonSid = []byte("Sid")
var ffjKeySmallPayloadFFJsonTt = []byte("Tt")
var ffjKeySmallPayloadFFJsonGr = []byte("Gr")
var ffjKeySmallPayloadFFJsonUuid = []byte("Uuid")
var ffjKeySmallPayloadFFJsonIp = []byte("Ip")
var ffjKeySmallPayloadFFJsonUa = []byte("Ua")
var ffjKeySmallPayloadFFJsonTz = []byte("Tz")
var ffjKeySmallPayloadFFJsonV = []byte("V")
// UnmarshalJSON umarshall json - template of ffjson
func (j *SmallPayloadFFJson) UnmarshalJSON(input []byte) error {
fs := fflib.NewFFLexer(input)
return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
}
// UnmarshalJSONFFLexer fast json unmarshall - template ffjson
func (j *SmallPayloadFFJson) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error {
var err error
currentKey := ffjtSmallPayloadFFJsonbase
_ = currentKey
tok := fflib.FFTok_init
wantedTok := fflib.FFTok_init
mainparse:
for {
tok = fs.Scan()
// println(fmt.Sprintf("debug: tok: %v state: %v", tok, state))
if tok == fflib.FFTok_error {
goto tokerror
}
switch state {
case fflib.FFParse_map_start:
if tok != fflib.FFTok_left_bracket {
wantedTok = fflib.FFTok_left_bracket
goto wrongtokenerror
}
state = fflib.FFParse_want_key
continue
case fflib.FFParse_after_value:
if tok == fflib.FFTok_comma {
state = fflib.FFParse_want_key
} else if tok == fflib.FFTok_right_bracket {
goto done
} else {
wantedTok = fflib.FFTok_comma
goto wrongtokenerror
}
case fflib.FFParse_want_key:
// json {} ended. goto exit. woo.
if tok == fflib.FFTok_right_bracket {
goto done
}
if tok != fflib.FFTok_string {
wantedTok = fflib.FFTok_string
goto wrongtokenerror
}
kn := fs.Output.Bytes()
if len(kn) <= 0 {
// "" case. hrm.
currentKey = ffjtSmallPayloadFFJsonnosuchkey
state = fflib.FFParse_want_colon
goto mainparse
} else {
switch kn[0] {
case 'G':
if bytes.Equal(ffjKeySmallPayloadFFJsonGr, kn) {
currentKey = ffjtSmallPayloadFFJsonGr
state = fflib.FFParse_want_colon
goto mainparse
}
case 'I':
if bytes.Equal(ffjKeySmallPayloadFFJsonIp, kn) {
currentKey = ffjtSmallPayloadFFJsonIp
state = fflib.FFParse_want_colon
goto mainparse
}
case 'S':
if bytes.Equal(ffjKeySmallPayloadFFJsonSt, kn) {
currentKey = ffjtSmallPayloadFFJsonSt
state = fflib.FFParse_want_colon
goto mainparse
} else if bytes.Equal(ffjKeySmallPayloadFFJsonSid, kn) {
currentKey = ffjtSmallPayloadFFJsonSid
state = fflib.FFParse_want_colon
goto mainparse
}
case 'T':
if bytes.Equal(ffjKeySmallPayloadFFJsonTt, kn) {
currentKey = ffjtSmallPayloadFFJsonTt
state = fflib.FFParse_want_colon
goto mainparse
} else if bytes.Equal(ffjKeySmallPayloadFFJsonTz, kn) {
currentKey = ffjtSmallPayloadFFJsonTz
state = fflib.FFParse_want_colon
goto mainparse
}
case 'U':
if bytes.Equal(ffjKeySmallPayloadFFJsonUuid, kn) {
currentKey = ffjtSmallPayloadFFJsonUuid
state = fflib.FFParse_want_colon
goto mainparse
} else if bytes.Equal(ffjKeySmallPayloadFFJsonUa, kn) {
currentKey = ffjtSmallPayloadFFJsonUa
state = fflib.FFParse_want_colon
goto mainparse
}
case 'V':
if bytes.Equal(ffjKeySmallPayloadFFJsonV, kn) {
currentKey = ffjtSmallPayloadFFJsonV
state = fflib.FFParse_want_colon
goto mainparse
}
}
if fflib.SimpleLetterEqualFold(ffjKeySmallPayloadFFJsonV, kn) {
currentKey = ffjtSmallPayloadFFJsonV
state = fflib.FFParse_want_colon
goto mainparse
}
if fflib.SimpleLetterEqualFold(ffjKeySmallPayloadFFJsonTz, kn) {
currentKey = ffjtSmallPayloadFFJsonTz
state = fflib.FFParse_want_colon
goto mainparse
}
if fflib.SimpleLetterEqualFold(ffjKeySmallPayloadFFJsonUa, kn) {
currentKey = ffjtSmallPayloadFFJsonUa
state = fflib.FFParse_want_colon
goto mainparse
}
if fflib.SimpleLetterEqualFold(ffjKeySmallPayloadFFJsonIp, kn) {
currentKey = ffjtSmallPayloadFFJsonIp
state = fflib.FFParse_want_colon
goto mainparse
}
if fflib.SimpleLetterEqualFold(ffjKeySmallPayloadFFJsonUuid, kn) {
currentKey = ffjtSmallPayloadFFJsonUuid
state = fflib.FFParse_want_colon
goto mainparse
}
if fflib.SimpleLetterEqualFold(ffjKeySmallPayloadFFJsonGr, kn) {
currentKey = ffjtSmallPayloadFFJsonGr
state = fflib.FFParse_want_colon
goto mainparse
}
if fflib.SimpleLetterEqualFold(ffjKeySmallPayloadFFJsonTt, kn) {
currentKey = ffjtSmallPayloadFFJsonTt
state = fflib.FFParse_want_colon
goto mainparse
}
if fflib.EqualFoldRight(ffjKeySmallPayloadFFJsonSid, kn) {
currentKey = ffjtSmallPayloadFFJsonSid
state = fflib.FFParse_want_colon
goto mainparse
}
if fflib.EqualFoldRight(ffjKeySmallPayloadFFJsonSt, kn) {
currentKey = ffjtSmallPayloadFFJsonSt
state = fflib.FFParse_want_colon
goto mainparse
}
currentKey = ffjtSmallPayloadFFJsonnosuchkey
state = fflib.FFParse_want_colon
goto mainparse
}
case fflib.FFParse_want_colon:
if tok != fflib.FFTok_colon {
wantedTok = fflib.FFTok_colon
goto wrongtokenerror
}
state = fflib.FFParse_want_value
continue
case fflib.FFParse_want_value:
if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null {
switch currentKey {
case ffjtSmallPayloadFFJsonSt:
goto handle_St
case ffjtSmallPayloadFFJsonSid:
goto handle_Sid
case ffjtSmallPayloadFFJsonTt:
goto handle_Tt
case ffjtSmallPayloadFFJsonGr:
goto handle_Gr
case ffjtSmallPayloadFFJsonUuid:
goto handle_Uuid
case ffjtSmallPayloadFFJsonIp:
goto handle_Ip
case ffjtSmallPayloadFFJsonUa:
goto handle_Ua
case ffjtSmallPayloadFFJsonTz:
goto handle_Tz
case ffjtSmallPayloadFFJsonV:
goto handle_V
case ffjtSmallPayloadFFJsonnosuchkey:
err = fs.SkipField(tok)
if err != nil {
return fs.WrapErr(err)
}
state = fflib.FFParse_after_value
goto mainparse
}
} else {
goto wantedvalue
}
}
}
handle_St:
/* handler: j.St type=int kind=int quoted=false*/
{
if tok != fflib.FFTok_integer && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok))
}
}
{
if tok == fflib.FFTok_null {
} else {
tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64)
if err != nil {
return fs.WrapErr(err)
}
j.St = int(tval)
}
}
state = fflib.FFParse_after_value
goto mainparse
handle_Sid:
/* handler: j.Sid type=int kind=int quoted=false*/
{
if tok != fflib.FFTok_integer && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok))
}
}
{
if tok == fflib.FFTok_null {
} else {
tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64)
if err != nil {
return fs.WrapErr(err)
}
j.Sid = int(tval)
}
}
state = fflib.FFParse_after_value
goto mainparse
handle_Tt:
/* handler: j.Tt type=string kind=string quoted=false*/
{
{
if tok != fflib.FFTok_string && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok))
}
}
if tok == fflib.FFTok_null {
} else {
outBuf := fs.Output.Bytes()
j.Tt = string(string(outBuf))
}
}
state = fflib.FFParse_after_value
goto mainparse
handle_Gr:
/* handler: j.Gr type=int kind=int quoted=false*/
{
if tok != fflib.FFTok_integer && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok))
}
}
{
if tok == fflib.FFTok_null {
} else {
tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64)
if err != nil {
return fs.WrapErr(err)
}
j.Gr = int(tval)
}
}
state = fflib.FFParse_after_value
goto mainparse
handle_Uuid:
/* handler: j.Uuid type=string kind=string quoted=false*/
{
{
if tok != fflib.FFTok_string && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok))
}
}
if tok == fflib.FFTok_null {
} else {
outBuf := fs.Output.Bytes()
j.Uuid = string(string(outBuf))
}
}
state = fflib.FFParse_after_value
goto mainparse
handle_Ip:
/* handler: j.Ip type=string kind=string quoted=false*/
{
{
if tok != fflib.FFTok_string && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok))
}
}
if tok == fflib.FFTok_null {
} else {
outBuf := fs.Output.Bytes()
j.Ip = string(string(outBuf))
}
}
state = fflib.FFParse_after_value
goto mainparse
handle_Ua:
/* handler: j.Ua type=string kind=string quoted=false*/
{
{
if tok != fflib.FFTok_string && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok))
}
}
if tok == fflib.FFTok_null {
} else {
outBuf := fs.Output.Bytes()
j.Ua = string(string(outBuf))
}
}
state = fflib.FFParse_after_value
goto mainparse
handle_Tz:
/* handler: j.Tz type=int kind=int quoted=false*/
{
if tok != fflib.FFTok_integer && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok))
}
}
{
if tok == fflib.FFTok_null {
} else {
tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64)
if err != nil {
return fs.WrapErr(err)
}
j.Tz = int(tval)
}
}
state = fflib.FFParse_after_value
goto mainparse
handle_V:
/* handler: j.V type=int kind=int quoted=false*/
{
if tok != fflib.FFTok_integer && tok != fflib.FFTok_null {
return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok))
}
}
{
if tok == fflib.FFTok_null {
} else {
tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64)
if err != nil {
return fs.WrapErr(err)
}
j.V = int(tval)
}
}
state = fflib.FFParse_after_value
goto mainparse
wantedvalue:
return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok))
wrongtokenerror:
return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String()))
tokerror:
if fs.BigError != nil {
return fs.WrapErr(fs.BigError)
}
err = fs.Error.ToError()
if err != nil {
return fs.WrapErr(err)
}
panic("ffjson-generated: unreachable, please report bug.")
done:
return nil
}