(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
memo=None, _w=WHITESPACE.match, _ws=WHITESPACE_STR)
| 135 | |
| 136 | |
| 137 | def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook, |
| 138 | memo=None, _w=WHITESPACE.match, _ws=WHITESPACE_STR): |
| 139 | s, end = s_and_end |
| 140 | pairs = [] |
| 141 | pairs_append = pairs.append |
| 142 | # Backwards compatibility |
| 143 | if memo is None: |
| 144 | memo = {} |
| 145 | memo_get = memo.setdefault |
| 146 | # Use a slice to prevent IndexError from being raised, the following |
| 147 | # check will raise a more specific ValueError if the string is empty |
| 148 | nextchar = s[end:end + 1] |
| 149 | # Normally we expect nextchar == '"' |
| 150 | if nextchar != '"': |
| 151 | if nextchar in _ws: |
| 152 | end = _w(s, end).end() |
| 153 | nextchar = s[end:end + 1] |
| 154 | # Trivial empty object |
| 155 | if nextchar == '}': |
| 156 | if object_pairs_hook is not None: |
| 157 | result = object_pairs_hook(pairs) |
| 158 | return result, end + 1 |
| 159 | pairs = {} |
| 160 | if object_hook is not None: |
| 161 | pairs = object_hook(pairs) |
| 162 | return pairs, end + 1 |
| 163 | elif nextchar != '"': |
| 164 | raise JSONDecodeError( |
| 165 | "Expecting property name enclosed in double quotes", s, end) |
| 166 | end += 1 |
| 167 | while True: |
| 168 | key, end = scanstring(s, end, strict) |
| 169 | key = memo_get(key, key) |
| 170 | # To skip some function call overhead we optimize the fast paths where |
| 171 | # the JSON key separator is ": " or just ":". |
| 172 | if s[end:end + 1] != ':': |
| 173 | end = _w(s, end).end() |
| 174 | if s[end:end + 1] != ':': |
| 175 | raise JSONDecodeError("Expecting ':' delimiter", s, end) |
| 176 | end += 1 |
| 177 | |
| 178 | try: |
| 179 | if s[end] in _ws: |
| 180 | end += 1 |
| 181 | if s[end] in _ws: |
| 182 | end = _w(s, end + 1).end() |
| 183 | except IndexError: |
| 184 | pass |
| 185 | |
| 186 | try: |
| 187 | value, end = scan_once(s, end) |
| 188 | except StopIteration as err: |
| 189 | raise JSONDecodeError("Expecting value", s, err.value) from None |
| 190 | pairs_append((key, value)) |
| 191 | try: |
| 192 | nextchar = s[end] |
| 193 | if nextchar in _ws: |
| 194 | end = _w(s, end + 1).end() |
nothing calls this directly
no test coverage detected
searching dependent graphs…