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 // Package json implements encoding and decoding of JSON objects as defined in | 5 // Package json implements encoding and decoding of JSON objects as defined in |
6 // RFC 4627. | 6 // RFC 4627. |
7 // | 7 // |
8 // See "JSON and Go" for an introduction to this package: | 8 // See "JSON and Go" for an introduction to this package: |
9 // http://golang.org/doc/articles/json_and_go.html | 9 // http://golang.org/doc/articles/json_and_go.html |
10 package json | 10 package json |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 switch r := r.(type) { | 217 switch r := r.(type) { |
218 case error: | 218 case error: |
219 err = r | 219 err = r |
220 case string: | 220 case string: |
221 err = errors.New(r) | 221 err = errors.New(r) |
222 default: | 222 default: |
223 panic(r) | 223 panic(r) |
224 } | 224 } |
225 } | 225 } |
226 }() | 226 }() |
| 227 |
227 e.reflectValue(reflect.ValueOf(v)) | 228 e.reflectValue(reflect.ValueOf(v)) |
228 return nil | 229 return nil |
229 } | 230 } |
230 | 231 |
231 func (e *encodeState) error(err error) { | 232 func (e *encodeState) error(err error) { |
232 panic(err) | 233 panic(err) |
233 } | 234 } |
234 | 235 |
235 var byteSliceType = reflect.TypeOf([]byte(nil)) | 236 var byteSliceType = reflect.TypeOf([]byte(nil)) |
236 | 237 |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 } | 699 } |
699 | 700 |
700 fieldCache.Lock() | 701 fieldCache.Lock() |
701 if fieldCache.m == nil { | 702 if fieldCache.m == nil { |
702 fieldCache.m = map[reflect.Type][]field{} | 703 fieldCache.m = map[reflect.Type][]field{} |
703 } | 704 } |
704 fieldCache.m[t] = f | 705 fieldCache.m[t] = f |
705 fieldCache.Unlock() | 706 fieldCache.Unlock() |
706 return f | 707 return f |
707 } | 708 } |
LEFT | RIGHT |