((s, end), encoding, strict, scan_once, object_hook,
object_pairs_hook, memo=None,
_w=WHITESPACE.match, _ws=WHITESPACE_STR)
| 178 | WHITESPACE_STR = ' \t\n\r' |
| 179 | |
| 180 | def JSONObject((s, end), encoding, strict, scan_once, object_hook, |
| 181 | object_pairs_hook, memo=None, |
| 182 | _w=WHITESPACE.match, _ws=WHITESPACE_STR): |
| 183 | # Backwards compatibility |
| 184 | if memo is None: |
| 185 | memo = {} |
| 186 | memo_get = memo.setdefault |
| 187 | pairs = [] |
| 188 | # Use a slice to prevent IndexError from being raised, the following |
| 189 | # check will raise a more specific ValueError if the string is empty |
| 190 | nextchar = s[end:end + 1] |
| 191 | # Normally we expect nextchar == '"' |
| 192 | if nextchar != '"': |
| 193 | if nextchar in _ws: |
| 194 | end = _w(s, end).end() |
| 195 | nextchar = s[end:end + 1] |
| 196 | # Trivial empty object |
| 197 | if nextchar == '}': |
| 198 | if object_pairs_hook is not None: |
| 199 | result = object_pairs_hook(pairs) |
| 200 | return result, end + 1 |
| 201 | pairs = {} |
| 202 | if object_hook is not None: |
| 203 | pairs = object_hook(pairs) |
| 204 | return pairs, end + 1 |
| 205 | elif nextchar != '"': |
| 206 | raise JSONDecodeError("Expecting property name", s, end) |
| 207 | end += 1 |
| 208 | while True: |
| 209 | key, end = scanstring(s, end, encoding, strict) |
| 210 | key = memo_get(key, key) |
| 211 | |
| 212 | # To skip some function call overhead we optimize the fast paths where |
| 213 | # the JSON key separator is ": " or just ":". |
| 214 | if s[end:end + 1] != ':': |
| 215 | end = _w(s, end).end() |
| 216 | if s[end:end + 1] != ':': |
| 217 | raise JSONDecodeError("Expecting : delimiter", s, end) |
| 218 | |
| 219 | end += 1 |
| 220 | |
| 221 | try: |
| 222 | if s[end] in _ws: |
| 223 | end += 1 |
| 224 | if s[end] in _ws: |
| 225 | end = _w(s, end + 1).end() |
| 226 | except IndexError: |
| 227 | pass |
| 228 | |
| 229 | try: |
| 230 | value, end = scan_once(s, end) |
| 231 | except StopIteration: |
| 232 | raise JSONDecodeError("Expecting object", s, end) |
| 233 | pairs.append((key, value)) |
| 234 | |
| 235 | try: |
| 236 | nextchar = s[end] |
| 237 | if nextchar in _ws: |
nothing calls this directly
no test coverage detected