LEFT | RIGHT |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Represents JSON data structure using native Go types: booleans, floats, | 5 // Represents JSON data structure using native Go types: booleans, floats, |
6 // strings, arrays, and maps. | 6 // strings, arrays, and maps. |
7 | 7 |
8 package json | 8 package json |
9 | 9 |
10 import ( | 10 import ( |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 582 } |
583 | 583 |
584 // literalStore decodes a literal stored in item into v. | 584 // literalStore decodes a literal stored in item into v. |
585 // | 585 // |
586 // fromQuoted indicates whether this literal came from unwrapping a | 586 // fromQuoted indicates whether this literal came from unwrapping a |
587 // string from the ",string" struct tag option. this is used only to | 587 // string from the ",string" struct tag option. this is used only to |
588 // produce more helpful error messages. | 588 // produce more helpful error messages. |
589 func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool
) { | 589 func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool
) { |
590 // Check for unmarshaler. | 590 // Check for unmarshaler. |
591 if len(item) == 0 { | 591 if len(item) == 0 { |
592 //Empty string given | 592 //Empty string given |
593 » » v.Set(reflect.Zero(v.Type())) | 593 » » d.saveError(fmt.Errorf("json: invalid use of ,string struct tag,
trying to unmarshal %q into %v", item, v.Type())) |
594 return | 594 return |
595 } | 595 } |
596 wantptr := item[0] == 'n' // null | 596 wantptr := item[0] == 'n' // null |
597 unmarshaler, pv := d.indirect(v, wantptr) | 597 unmarshaler, pv := d.indirect(v, wantptr) |
598 if unmarshaler != nil { | 598 if unmarshaler != nil { |
599 err := unmarshaler.UnmarshalJSON(item) | 599 err := unmarshaler.UnmarshalJSON(item) |
600 if err != nil { | 600 if err != nil { |
601 d.error(err) | 601 d.error(err) |
602 } | 602 } |
603 return | 603 return |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 return b[0:w], true | 975 return b[0:w], true |
976 } | 976 } |
977 | 977 |
978 // The following is issue 3069. | 978 // The following is issue 3069. |
979 | 979 |
980 // BUG(rsc): This package ignores anonymous (embedded) struct fields | 980 // BUG(rsc): This package ignores anonymous (embedded) struct fields |
981 // during encoding and decoding. A future version may assign meaning | 981 // during encoding and decoding. A future version may assign meaning |
982 // to them. To force an anonymous field to be ignored in all future | 982 // to them. To force an anonymous field to be ignored in all future |
983 // versions of this package, use an explicit `json:"-"` tag in the struct | 983 // versions of this package, use an explicit `json:"-"` tag in the struct |
984 // definition. | 984 // definition. |
LEFT | RIGHT |