Simple JSON decoder Performs the following translations in decoding by default: +---------------+-------------------+ | JSON | Python | +===============+===================+ | object | dict | +---------------+-------
| 290 | return values, end |
| 291 | |
| 292 | class JSONDecoder(object): |
| 293 | """Simple JSON <http://json.org> decoder |
| 294 | |
| 295 | Performs the following translations in decoding by default: |
| 296 | |
| 297 | +---------------+-------------------+ |
| 298 | | JSON | Python | |
| 299 | +===============+===================+ |
| 300 | | object | dict | |
| 301 | +---------------+-------------------+ |
| 302 | | array | list | |
| 303 | +---------------+-------------------+ |
| 304 | | string | str, unicode | |
| 305 | +---------------+-------------------+ |
| 306 | | number (int) | int, long | |
| 307 | +---------------+-------------------+ |
| 308 | | number (real) | float | |
| 309 | +---------------+-------------------+ |
| 310 | | true | True | |
| 311 | +---------------+-------------------+ |
| 312 | | false | False | |
| 313 | +---------------+-------------------+ |
| 314 | | null | None | |
| 315 | +---------------+-------------------+ |
| 316 | |
| 317 | When allow_nan=True, it also understands |
| 318 | ``NaN``, ``Infinity``, and ``-Infinity`` as |
| 319 | their corresponding ``float`` values, which is outside the JSON spec. |
| 320 | |
| 321 | """ |
| 322 | |
| 323 | def __init__(self, encoding=None, object_hook=None, parse_float=None, |
| 324 | parse_int=None, parse_constant=None, strict=True, |
| 325 | object_pairs_hook=None, allow_nan=False, |
| 326 | array_hook=None): |
| 327 | """ |
| 328 | *encoding* determines the encoding used to interpret any |
| 329 | :class:`str` objects decoded by this instance (``'utf-8'`` by |
| 330 | default). It has no effect when decoding :class:`unicode` objects. |
| 331 | |
| 332 | Note that currently only encodings that are a superset of ASCII work, |
| 333 | strings of other encodings should be passed in as :class:`unicode`. |
| 334 | |
| 335 | *object_hook*, if specified, will be called with the result of every |
| 336 | JSON object decoded and its return value will be used in place of the |
| 337 | given :class:`dict`. This can be used to provide custom |
| 338 | deserializations (e.g. to support JSON-RPC class hinting). |
| 339 | |
| 340 | *object_pairs_hook* is an optional function that will be called with |
| 341 | the result of any object literal decode with an ordered list of pairs. |
| 342 | The return value of *object_pairs_hook* will be used instead of the |
| 343 | :class:`dict`. This feature can be used to implement custom decoders |
| 344 | that rely on the order that the key and value pairs are decoded (for |
| 345 | example, :func:`collections.OrderedDict` will remember the order of |
| 346 | insertion). If *object_hook* is also defined, the *object_pairs_hook* |
| 347 | takes priority. |
| 348 | |
| 349 | *parse_float*, if specified, will be called with the string of every |
no outgoing calls
no test coverage detected
searching dependent graphs…