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

Side by Side Diff: src/pkg/encoding/json/encode.go

Issue 6997045: code review 6997045: encoding/json: A JSON tag can be any valid JSON string. (Closed)
Patch Set: diff -r a244dfa507e0 https://code.google.com/p/go Created 11 years, 3 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:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/encoding/json/tagkey_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/encoding/json/tagkey_test.go » ('j') | no next file with comments »

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