MCPcopy
hub / github.com/tkfy920/qstock / decode

Function decode

data/demjson.py:5603–5760  ·  view source on GitHub ↗

Decodes a JSON-encoded string into a Python object. == Optional arguments == * 'encoding' (string, default None) This argument provides a hint regarding the character encoding that the input text is assumed to be in (if it is not already a unicode string type).

(txt, encoding=None, **kwargs)

Source from the content-addressed store, hash-verified

5601
5602
5603def decode(txt, encoding=None, **kwargs):
5604 """Decodes a JSON-encoded string into a Python object.
5605
5606 == Optional arguments ==
5607
5608 * 'encoding' (string, default None)
5609
5610 This argument provides a hint regarding the character encoding
5611 that the input text is assumed to be in (if it is not already a
5612 unicode string type).
5613
5614 If set to None then autodetection of the encoding is attempted
5615 (see discussion above). Otherwise this argument should be the
5616 name of a registered codec (see the standard 'codecs' module).
5617
5618 * 'strict' (Boolean, default False)
5619
5620 If 'strict' is set to True, then those strings that are not
5621 entirely strictly conforming to JSON will result in a
5622 JSONDecodeError exception.
5623
5624 * 'return_errors' (Boolean, default False)
5625
5626 Controls the return value from this function. If False, then
5627 only the Python equivalent object is returned on success, or
5628 an error will be raised as an exception.
5629
5630 If True then a 2-tuple is returned: (object, error_list). The
5631 error_list will be an empty list [] if the decoding was
5632 successful, otherwise it will be a list of all the errors
5633 encountered. Note that it is possible for an object to be
5634 returned even if errors were encountered.
5635
5636 * 'return_stats' (Boolean, default False)
5637
5638 Controls whether statistics about the decoded JSON document
5639 are returns (and instance of decode_statistics).
5640
5641 If True, then the stats object will be added to the end of the
5642 tuple returned. If return_errors is also set then a 3-tuple
5643 is returned, otherwise a 2-tuple is returned.
5644
5645 * 'write_errors' (Boolean OR File-like object, default False)
5646
5647 Controls what to do with errors.
5648
5649 - If False, then the first decoding error is raised as an exception.
5650 - If True, then errors will be printed out to sys.stderr.
5651 - If a File-like object, then errors will be printed to that file.
5652
5653 The write_errors and return_errors arguments can be set
5654 independently.
5655
5656 * 'filename_for_errors' (string or None)
5657
5658 Provides a filename to be used when writting error messages.
5659
5660 * 'allow_xxx', 'warn_xxx', and 'forbid_xxx' (Booleans)

Callers 2

decode_fileFunction · 0.85
_lintcheck_dataMethod · 0.85

Calls 5

decodeMethod · 0.95
JSONClass · 0.85
appendMethod · 0.80
copyMethod · 0.45
pretty_descriptionMethod · 0.45

Tested by

no test coverage detected