Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(361)

Delta Between Two Patch Sets: src/pkg/encoding/json/decode.go

Issue 6035050: code review 6035050: encoding/json: Fix panic when trying to unmarshal the e... (Closed)
Left Patch Set: Created 11 years, 11 months ago
Right Patch Set: diff -r 5a1d471de6d2 https://code.google.com/p/go Created 11 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/encoding/json/decode_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 d.literalStore(d.data[start:d.off], v, false) 581 d.literalStore(d.data[start:d.off], v, false)
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 {
592 //Empty string given
593 d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type()))
594 return
595 }
591 wantptr := item[0] == 'n' // null 596 wantptr := item[0] == 'n' // null
592 unmarshaler, pv := d.indirect(v, wantptr) 597 unmarshaler, pv := d.indirect(v, wantptr)
593 if unmarshaler != nil { 598 if unmarshaler != nil {
594 err := unmarshaler.UnmarshalJSON(item) 599 err := unmarshaler.UnmarshalJSON(item)
595 if err != nil { 600 if err != nil {
596 d.error(err) 601 d.error(err)
597 } 602 }
598 return 603 return
599 } 604 }
600 v = pv 605 v = pv
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 return b[0:w], true 975 return b[0:w], true
971 } 976 }
972 977
973 // The following is issue 3069. 978 // The following is issue 3069.
974 979
975 // BUG(rsc): This package ignores anonymous (embedded) struct fields 980 // BUG(rsc): This package ignores anonymous (embedded) struct fields
976 // during encoding and decoding. A future version may assign meaning 981 // during encoding and decoding. A future version may assign meaning
977 // 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
978 // 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
979 // definition. 984 // definition.
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b