OLD | NEW |
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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 430 } |
431 return | 431 return |
432 } | 432 } |
433 | 433 |
434 func isValidTag(s string) bool { | 434 func isValidTag(s string) bool { |
435 if s == "" { | 435 if s == "" { |
436 return false | 436 return false |
437 } | 437 } |
438 for _, c := range s { | 438 for _, c := range s { |
439 switch { | 439 switch { |
440 » » case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~", c): | 440 » » case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c): |
441 // Backslash and quote chars are reserved, but | 441 // Backslash and quote chars are reserved, but |
442 // otherwise any punctuation chars are allowed | 442 // otherwise any punctuation chars are allowed |
443 // in a tag name. | 443 // in a tag name. |
444 default: | 444 default: |
445 if !unicode.IsLetter(c) && !unicode.IsDigit(c) { | 445 if !unicode.IsLetter(c) && !unicode.IsDigit(c) { |
446 return false | 446 return false |
447 } | 447 } |
448 } | 448 } |
449 } | 449 } |
450 return true | 450 return true |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 } | 694 } |
695 | 695 |
696 fieldCache.Lock() | 696 fieldCache.Lock() |
697 if fieldCache.m == nil { | 697 if fieldCache.m == nil { |
698 fieldCache.m = map[reflect.Type][]field{} | 698 fieldCache.m = map[reflect.Type][]field{} |
699 } | 699 } |
700 fieldCache.m[t] = f | 700 fieldCache.m[t] = f |
701 fieldCache.Unlock() | 701 fieldCache.Unlock() |
702 return f | 702 return f |
703 } | 703 } |
OLD | NEW |