本文整理汇总了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)
}