本文整理匯總了Golang中github.com/pquerna/ffjson/fflib/v1.NewFFLexer函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewFFLexer函數的具體用法?Golang NewFFLexer怎麽用?Golang NewFFLexer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewFFLexer函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DecodeFast
// DecodeFast will unmarshal the data if fast unmarshal is available.
// This function can be used if you want to be sure the fast
// unmarshal is used or in testing.
// If you would like to have fallback to encoding/json you can use the
// regular Decode() method.
func (d *Decoder) DecodeFast(data []byte, v interface{}) error {
f, ok := v.(unmarshalFaster)
if !ok {
return errors.New("ffjson unmarshal not available for type " + reflect.TypeOf(v).String())
}
if d.fs == nil {
d.fs = fflib.NewFFLexer(data)
} else {
d.fs.Reset(data)
}
return f.UnmarshalJSONFFLexer(d.fs, fflib.FFParse_map_start)
}
示例2: Unmarshal
// Unmarshal will act the same way as json.Unmarshal, except
// it will choose the ffjson unmarshal function before falling
// back to using json.Unmarshal.
// The overhead of unmarshal is lower than on Marshal,
// however this should still provide a speedup for your encoding.
// It is ok to call this function even if no ffjson code has been
// generated for the data type you pass in the interface.
func Unmarshal(data []byte, v interface{}) error {
f, ok := v.(unmarshalFaster)
if ok {
fs := fflib.NewFFLexer(data)
return f.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
}
j, ok := v.(json.Unmarshaler)
if ok {
return j.UnmarshalJSON(data)
}
return json.Unmarshal(data, v)
}
示例3: Decode
// Decode the data in the supplied data slice.
func (d *Decoder) Decode(data []byte, v interface{}) error {
f, ok := v.(unmarshalFaster)
if ok {
if d.fs == nil {
d.fs = fflib.NewFFLexer(data)
} else {
d.fs.Reset(data)
}
return f.UnmarshalJSONFFLexer(d.fs, fflib.FFParse_map_start)
}
um, ok := v.(json.Unmarshaler)
if ok {
return um.UnmarshalJSON(data)
}
return json.Unmarshal(data, v)
}
示例4: UnmarshalJSON
func (uj *Pos2D) UnmarshalJSON(input []byte) error {
fs := fflib.NewFFLexer(input)
return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
}
示例5: UnmarshalJSON
func (uj *ServiceDefinition) UnmarshalJSON(input []byte) error {
fs := fflib.NewFFLexer(input)
return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
}
示例6: UnmarshalJSON
func (uj *MtBroadCastMessage) UnmarshalJSON(input []byte) error {
fs := fflib.NewFFLexer(input)
return uj.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start)
}