Exemple #1
0
// 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()
}
Exemple #2
0
// 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
	}
}
Exemple #3
0
// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface.
func (v *Int16) UnmarshalEasyJSON(l *jlexer.Lexer) {
	if l.IsNull() {
		l.Skip()
		*v = Int16{}
	} else {
		v.V = l.Int16()
		v.Defined = true
	}
}
Exemple #4
0
// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface.
func (v *Optional) UnmarshalEasyJSON(l *jlexer.Lexer) {
	if l.IsNull() {
		l.Skip()
		*v = Optional{}
	} else {
		v.V = l.Optional()
		v.Defined = true
	}
}
Exemple #5
0
// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface.
func (v *String) UnmarshalEasyJSON(l *jlexer.Lexer) {
	if l.IsNull() {
		l.Skip()
		*v = String{}
	} else {
		v.V = l.String()
		v.Defined = true
	}
}
Exemple #6
0
// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface.
func (v *Bool) UnmarshalEasyJSON(l *jlexer.Lexer) {
	if l.IsNull() {
		l.Skip()
		*v = Bool{}
	} else {
		v.V = l.Bool()
		v.Defined = true
	}
}
Exemple #7
0
// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface.
func (v *Uint) UnmarshalEasyJSON(l *jlexer.Lexer) {
	if l.IsNull() {
		l.Skip()
		*v = Uint{}
	} else {
		v.V = l.Uint()
		v.Defined = true
	}
}
Exemple #8
0
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
	}
}
Exemple #9
0
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)
	}
}
Exemple #10
0
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)
	}
}
Exemple #11
0
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]
	}
}
Exemple #12
0
func (r *Password) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*r = Password(data)
	}
}
Exemple #13
0
func (b *Base64) UnmarshalJSON(data []byte) error {
	l := jlexer.Lexer{Data: data}
	b.UnmarshalEasyJSON(&l)
	return l.Error()
}
Exemple #14
0
func (v *YahooRate) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson_decode_finance_provider_yahoo_YahooRate(&r, v)
	return r.Error()
}
Exemple #15
0
func (r *Password) UnmarshalJSON(data []byte) error {
	l := jlexer.Lexer{Data: data}
	r.UnmarshalEasyJSON(&l)
	return l.Error()
}
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('}')
}
Exemple #17
0
func (u *ISBN10) UnmarshalJSON(data []byte) error {
	l := jlexer.Lexer{Data: data}
	u.UnmarshalEasyJSON(&l)
	return l.Error()
}
Exemple #18
0
func (u *MAC) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*u = MAC(data)
	}
}
Exemple #19
0
func (h *Hostname) UnmarshalJSON(data []byte) error {
	l := jlexer.Lexer{Data: data}
	h.UnmarshalEasyJSON(&l)
	return l.Error()
}
Exemple #20
0
func (e *Email) UnmarshalJSON(data []byte) error {
	l := jlexer.Lexer{Data: data}
	e.UnmarshalEasyJSON(&l)
	return l.Error()
}
Exemple #21
0
func (e *Email) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*e = Email(data)
	}
}
Exemple #22
0
// MarshalJSON implements a standard json marshaler interface.
func (v *Uint) UnmarshalJSON(data []byte) error {
	l := jlexer.Lexer{}
	v.UnmarshalEasyJSON(&l)
	return l.Error()
}
Exemple #23
0
func (h *Hostname) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*h = Hostname(data)
	}
}
Exemple #24
0
func (u *CreditCard) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*u = CreditCard(data)
	}
}
Exemple #25
0
func (u *UUID5) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*u = UUID5(data)
	}
}
Exemple #26
0
func (u *SSN) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*u = SSN(data)
	}
}
Exemple #27
0
func (u *ISBN10) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*u = ISBN10(data)
	}
}
Exemple #28
0
func (h *HexColor) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*h = HexColor(data)
	}
}
func (v *A) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson_decode_go_serialization_benchmarks_A(&r, v)
	return r.Error()
}
Exemple #30
0
func (r *RGBColor) UnmarshalEasyJSON(in *jlexer.Lexer) {
	if data := in.String(); in.Ok() {
		*r = RGBColor(data)
	}
}