Skip to content
Snippets Groups Projects
Commit 86b358ddf4ec authored by Bob Ippolito's avatar Bob Ippolito
Browse files
parent 31f4f0fb52d8
No related branches found
No related tags found
No related merge requests found
Version 2.1.7 released 2011-XX-XX
* Updated documentation with information about JSONDecodeError
* Force unicode linebreak characters to be escaped (U+2028 and U+2029)
http://timelessrepo.com/json-isnt-a-javascript-subset
* Moved documentation from a git submodule to
......
......@@ -206,7 +206,8 @@
.. function:: load(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, use_decimal[, **kw]]]]]]]]])
Deserialize *fp* (a ``.read()``-supporting file-like object containing a JSON
document) to a Python object.
document) to a Python object. :exc:`JSONDecodeError` will be
raised if the given JSON document is not valid.
If the contents of *fp* are encoded with an ASCII based encoding other than
UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be specified.
......@@ -273,7 +274,8 @@
.. function:: loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, object_pairs_hook[, use_decimal[, **kw]]]]]]]]])
Deserialize *s* (a :class:`str` or :class:`unicode` instance containing a JSON
document) to a Python object.
document) to a Python object. :exc:`JSONDecodeError` will be
raised if the given JSON document is not valid.
If *s* is a :class:`str` instance and is encoded with an ASCII based encoding
other than UTF-8 (e.g. latin-1), then an appropriate *encoding* name must be
......@@ -373,6 +375,9 @@
appropriate solution is decode *s* to :class:`unicode` prior to calling
decode.
:exc:`JSONDecodeError` will be raised if the given JSON
document is not valid.
.. method:: raw_decode(s)
Decode a JSON document from *s* (a :class:`str` or :class:`unicode`
......@@ -382,6 +387,8 @@
This can be used to decode a JSON document from a string that may have
extraneous data at the end.
:exc:`JSONDecodeError` will be raised if the given JSON
document is not valid.
.. class:: JSONEncoder([skipkeys[, ensure_ascii[, check_circular[, allow_nan[, sort_keys[, indent[, separators[, encoding[, default]]]]]]]]])
......@@ -504,3 +511,42 @@
.. versionchanged:: 2.1.0
New in 2.1.0
Exceptions
----------
.. exception:: JSONDecodeError(msg, doc, pos[, end])
Subclass of :exc:`ValueError` with the following additional attributes:
.. attribute:: msg
The unformatted error message
.. attribute:: doc
The JSON document being parsed
.. attribute:: pos
The start index of doc where parsing failed
.. attribute:: end
The end index of doc where parsing failed (may be ``None``)
.. attribute:: lineno
The line corresponding to pos
.. attribute:: colno
The column corresponding to pos
.. attribute:: endlineno
The line corresponding to end (may be ``None``)
.. attribute:: endcolno
The column corresponding to end (may be ``None``)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment