Home | Trees | Indices | Help |
|
---|
|
Thin abstraction layer over the different available modules for decoding and encoding JSON data.
This module currently supports the following JSON modules:
The default behavior is to use ``simplejson`` if installed, and otherwise fallback to the standard library module. To explicitly tell SPARQLWrapper which module to use, invoke the `use()` function with the module name:
import jsonlayer jsonlayer.use('cjson')
In addition to choosing one of the above modules, you can also configure SPARQLWrapper to use custom decoding and encoding functions:
import jsonlayer jsonlayer.use(decode=my_decode, encode=my_encode)
|
|||
|
|||
|
|||
|
|||
|
|
|||
__package__ = None hash(x) |
|||
_decode = None hash(x) |
|||
_encode = None hash(x) |
|||
_initialized = False
|
|||
_using = None hash(x) |
|
Decode the given JSON string. :param string: the JSON string to decode :type string: basestring :return: the corresponding Python data structure :rtype: object |
Encode the given object as a JSON string. :param obj: the Python data structure to encode :type obj: object :return: the corresponding JSON string :rtype: basestring |
Set the JSON library that should be used, either by specifying a known module name, or by providing a decode and encode function. The modules "simplejson", "cjson", and "json" are currently supported for the ``module`` parameter. If provided, the ``decode`` parameter must be a callable that accepts a JSON string and returns a corresponding Python data structure. The ``encode`` callable must accept a Python data structure and return the corresponding JSON string. Exceptions raised by decoding and encoding should be propagated up unaltered. :param module: the name of the JSON library module to use, or the module object itself :type module: str or module :param decode: a function for decoding JSON strings :type decode: callable :param encode: a function for encoding objects as JSON strings :type encode: callable |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Feb 14 12:30:08 2016 | http://epydoc.sourceforge.net |