MCPcopy Index your code
hub / github.com/segmentio/encoding / decodeMapStringStringSlice

Method decodeMapStringStringSlice

json/decode.go:972–1055  ·  view source on GitHub ↗
(b []byte, p unsafe.Pointer)

Source from the content-addressed store, hash-verified

970}
971
972func (d decoder) decodeMapStringStringSlice(b []byte, p unsafe.Pointer) ([]byte, error) {
973 if hasNullPrefix(b) {
974 *(*unsafe.Pointer)(p) = nil
975 return b[4:], nil
976 }
977
978 if len(b) < 2 || b[0] != '{' {
979 return d.inputError(b, mapStringStringSliceType)
980 }
981
982 i := 0
983 m := *(*map[string][]string)(p)
984
985 if m == nil {
986 m = make(map[string][]string, 64)
987 }
988
989 var err error
990 var key string
991 var buf []string
992 input := b
993 stringSize := unsafe.Sizeof("")
994
995 b = b[1:]
996 for {
997 key = ""
998 buf = buf[:0]
999
1000 b = skipSpaces(b)
1001
1002 if len(b) != 0 && b[0] == '}' {
1003 *(*unsafe.Pointer)(p) = *(*unsafe.Pointer)(unsafe.Pointer(&m))
1004 return b[1:], nil
1005 }
1006
1007 if i != 0 {
1008 if len(b) == 0 {
1009 return b, syntaxError(b, "unexpected end of JSON input after object field value")
1010 }
1011 if b[0] != ',' {
1012 return b, syntaxError(b, "expected ',' after object field value but found '%c'", b[0])
1013 }
1014 b = skipSpaces(b[1:])
1015 }
1016
1017 if hasNullPrefix(b) {
1018 return b, syntaxError(b, "cannot decode object key string from 'null' value")
1019 }
1020
1021 b, err = d.decodeString(b, unsafe.Pointer(&key))
1022 if err != nil {
1023 return objectKeyError(b, err)
1024 }
1025 b = skipSpaces(b)
1026
1027 if len(b) == 0 {
1028 return b, syntaxError(b, "unexpected end of JSON input after object field key")
1029 }

Callers

nothing calls this directly

Calls 10

inputErrorMethod · 0.95
decodeStringMethod · 0.95
decodeSliceMethod · 0.95
parseValueMethod · 0.95
prependFieldMethod · 0.95
hasNullPrefixFunction · 0.85
skipSpacesFunction · 0.85
syntaxErrorFunction · 0.85
objectKeyErrorFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected