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

Method decodeMapStringBool

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

Source from the content-addressed store, hash-verified

1055}
1056
1057func (d decoder) decodeMapStringBool(b []byte, p unsafe.Pointer) ([]byte, error) {
1058 if hasNullPrefix(b) {
1059 *(*unsafe.Pointer)(p) = nil
1060 return b[4:], nil
1061 }
1062
1063 if len(b) < 2 || b[0] != '{' {
1064 return d.inputError(b, mapStringBoolType)
1065 }
1066
1067 i := 0
1068 m := *(*map[string]bool)(p)
1069
1070 if m == nil {
1071 m = make(map[string]bool, 64)
1072 }
1073
1074 var err error
1075 var key string
1076 var val bool
1077 input := b
1078
1079 b = b[1:]
1080 for {
1081 key = ""
1082 val = false
1083
1084 b = skipSpaces(b)
1085
1086 if len(b) != 0 && b[0] == '}' {
1087 *(*unsafe.Pointer)(p) = *(*unsafe.Pointer)(unsafe.Pointer(&m))
1088 return b[1:], nil
1089 }
1090
1091 if i != 0 {
1092 if len(b) == 0 {
1093 return b, syntaxError(b, "unexpected end of JSON input after object field value")
1094 }
1095 if b[0] != ',' {
1096 return b, syntaxError(b, "expected ',' after object field value but found '%c'", b[0])
1097 }
1098 b = skipSpaces(b[1:])
1099 }
1100
1101 if hasNullPrefix(b) {
1102 return b, syntaxError(b, "cannot decode object key string from 'null' value")
1103 }
1104
1105 b, err = d.decodeString(b, unsafe.Pointer(&key))
1106 if err != nil {
1107 return objectKeyError(b, err)
1108 }
1109 b = skipSpaces(b)
1110
1111 if len(b) == 0 {
1112 return b, syntaxError(b, "unexpected end of JSON input after object field key")
1113 }
1114 if b[0] != ':' {

Callers

nothing calls this directly

Calls 10

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