Decode a JSON document from ``s`` (a ``str`` or ``unicode`` beginning with a JSON document) and return a 2-tuple of the Python representation and the index in ``s`` where the document ended. This can be used to decode a JSON document from a string that may have extra
(self, s, idx=0)
| 406 | return obj |
| 407 | |
| 408 | def raw_decode(self, s, idx=0): |
| 409 | """Decode a JSON document from ``s`` (a ``str`` or ``unicode`` |
| 410 | beginning with a JSON document) and return a 2-tuple of the Python |
| 411 | representation and the index in ``s`` where the document ended. |
| 412 | |
| 413 | This can be used to decode a JSON document from a string that may |
| 414 | have extraneous data at the end. |
| 415 | |
| 416 | """ |
| 417 | try: |
| 418 | obj, end = self.scan_once(s, idx) |
| 419 | except StopIteration: |
| 420 | raise JSONDecodeError("No JSON object could be decoded", s, idx) |
| 421 | return obj, end |