本文整理匯總了Golang中github.com/mailru/easyjson/jlexer.Lexer類的典型用法代碼示例。如果您正苦於以下問題:Golang Lexer類的具體用法?Golang Lexer怎麽用?Golang Lexer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Lexer類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UnmarshalFromReader
// UnmarshalFromReader reads all the data in the reader and decodes as JSON into the object.
func UnmarshalFromReader(r io.Reader, v Unmarshaler) error {
data, err := ioutil.ReadAll(r)
if err != nil {
return err
}
l := jlexer.Lexer{Data: data}
v.UnmarshalEasyJSON(&l)
return l.Error()
}
示例2: UnmarshalEasyJSON
// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface.
func (v *Float64) UnmarshalEasyJSON(l *jlexer.Lexer) {
if l.IsNull() {
l.Skip()
*v = Float64{}
} else {
v.V = l.Float64()
v.Defined = true
}
}
示例3: UnmarshalEasyJSON
func (t *DateTime) UnmarshalEasyJSON(in *jlexer.Lexer) {
if data := in.String(); in.Ok() {
tt, err := ParseDateTime(data)
if err != nil {
in.AddError(err)
return
}
*t = tt
}
}
示例4: UnmarshalEasyJSON
func (d *Duration) UnmarshalEasyJSON(in *jlexer.Lexer) {
if data := in.String(); in.Ok() {
tt, err := ParseDuration(data)
if err != nil {
in.AddError(err)
return
}
*d = Duration(tt)
}
}
示例5: UnmarshalEasyJSON
func (t *Date) UnmarshalEasyJSON(in *jlexer.Lexer) {
if data := in.String(); in.Ok() {
tt, err := time.Parse(RFC3339FullDate, data)
if err != nil {
in.AddError(err)
return
}
*t = Date(tt)
}
}
示例6: UnmarshalEasyJSON
func (b *Base64) UnmarshalEasyJSON(in *jlexer.Lexer) {
if data := in.String(); in.Ok() {
enc := base64.StdEncoding
dbuf := make([]byte, enc.DecodedLen(len(data)))
n, err := enc.Decode(dbuf, []byte(data))
if err != nil {
in.AddError(err)
return
}
*b = dbuf[:n]
}
}
示例7: UnmarshalJSON
func (b *Base64) UnmarshalJSON(data []byte) error {
l := jlexer.Lexer{Data: data}
b.UnmarshalEasyJSON(&l)
return l.Error()
}
示例8: UnmarshalJSON
func (v *YahooRate) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson_decode_finance_provider_yahoo_YahooRate(&r, v)
return r.Error()
}
示例9: easyjson_decode_go_serialization_benchmarks_A
func easyjson_decode_go_serialization_benchmarks_A(in *jlexer.Lexer, out *A) {
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "Name":
out.Name = in.String()
case "BirthDay":
if data := in.Raw(); in.Ok() {
in.AddError((out.BirthDay).UnmarshalJSON(data))
}
case "Phone":
out.Phone = in.String()
case "Siblings":
out.Siblings = in.Int()
case "Spouse":
out.Spouse = in.Bool()
case "Money":
out.Money = in.Float64()
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
}
示例10: UnmarshalJSON
// MarshalJSON implements a standard json marshaler interface.
func (v *Uint) UnmarshalJSON(data []byte) error {
l := jlexer.Lexer{}
v.UnmarshalEasyJSON(&l)
return l.Error()
}
示例11: UnmarshalJSON
func (v *A) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
easyjson_decode_go_serialization_benchmarks_A(&r, v)
return r.Error()
}