package encoderimport ()// The names of a map whose keys may have the same name, of the v2 semantics, which a function, a method or the// kind of its key writes. The names of a map which is not sorted are checked as they are written ( see// appendMapKeyName ). The keys of a sorted map are sorted by their names, which puts the same names next to each// other, and checked by OpMapKey as the entries are written in that order, when the end of the map is// OpMapEndMayRepeatNames.// SameMapName reports whether key, the name of an entry of a sorted map as it is encoded with a comma after it ( see// MapItem ), is the name of the entry before it, prev, which is an error unless AllowDuplicateNamesOption.func ( *RuntimeContext, , []byte) bool {return .Option.Flag&AllowDuplicateNamesOption == 0 && string() == string()}// DuplicateMapNameError returns the error of key, the name of an entry of a sorted map as it is encoded with a comma// after it, which an entry before it has: out is the output before the name.func (, []byte) error { := jsonstring.AppendUnescaped(nil, [1:len()-2])return &errors.TextError{Err: errors.ErrDuplicateName, Name: string(), Out: }}// stringStart returns where the string whose closing quote is at end starts: the quote before it which no odd// number of backslashes precedes, which would escape it.func stringStart( []byte, int) int {for := - 1; >= 0; -- {if [] != '"' {continue } := 0for := - 1; >= 0 && [] == '\\'; -- { ++ }if %2 == 0 {return } }return0}// stringEnd returns where the string which starts at start ends: its closing quote.func stringEnd( []byte, int) int {for := + 1; < len(); ++ {switch [] {case'\\': ++case'"':return } }returnlen() - 1}// memberNames returns where the names of the members of the object obj start: the object is compact and valid.func memberNames( []byte) []int {var []int := 0 := falsefor := 0; < len(); ++ {switch [] {case'{', '[': ++ = [] == '{' && == 1case'}', ']': --case',': = == 1case'"':if { = append(, ) = false } = stringEnd(, ) } }return}
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.