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

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: diff -r 0324cadd9b98 https://code.google.com/p/go 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:
Left: Side by side diff | Download
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
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
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
rsc 2012/04/23 13:57:55 I don't see why the empty string should be treated
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
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.
LEFTRIGHT

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