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

Method decodeMapStringString

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

Source from the content-addressed store, hash-verified

889}
890
891func (d decoder) decodeMapStringString(b []byte, p unsafe.Pointer) ([]byte, error) {
892 if hasNullPrefix(b) {
893 *(*unsafe.Pointer)(p) = nil
894 return b[4:], nil
895 }
896
897 if len(b) < 2 || b[0] != '{' {
898 return d.inputError(b, mapStringStringType)
899 }
900
901 i := 0
902 m := *(*map[string]string)(p)
903
904 if m == nil {
905 m = make(map[string]string, 64)
906 }
907
908 var err error
909 var key string
910 var val string
911 input := b
912
913 b = b[1:]
914 for {
915 key = ""
916 val = ""
917
918 b = skipSpaces(b)
919
920 if len(b) != 0 && b[0] == '}' {
921 *(*unsafe.Pointer)(p) = *(*unsafe.Pointer)(unsafe.Pointer(&m))
922 return b[1:], nil
923 }
924
925 if i != 0 {
926 if len(b) == 0 {
927 return b, syntaxError(b, "unexpected end of JSON input after object field value")
928 }
929 if b[0] != ',' {
930 return b, syntaxError(b, "expected ',' after object field value but found '%c'", b[0])
931 }
932 b = skipSpaces(b[1:])
933 }
934
935 if hasNullPrefix(b) {
936 return b, syntaxError(b, "cannot decode object key string from 'null' value")
937 }
938
939 b, err = d.decodeString(b, unsafe.Pointer(&key))
940 if err != nil {
941 return objectKeyError(b, err)
942 }
943 b = skipSpaces(b)
944
945 if len(b) == 0 {
946 return b, syntaxError(b, "unexpected end of JSON input after object field key")
947 }
948 if b[0] != ':' {

Callers

nothing calls this directly

Calls 9

inputErrorMethod · 0.95
decodeStringMethod · 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