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