simplejson Namespace Reference


Namespaces

namespace  decoder
namespace  encoder
namespace  jsonfilter
namespace  scanner

Functions

def dump
def dumps
def load
def loads
def read
def write

Variables

string __version__ = '1.7.4'
list __all__
tuple _default_encoder
tuple _default_decoder = JSONDecoder(encoding=None, object_hook=None)


Function Documentation

def simplejson::dump (   obj,
  fp,
  skipkeys = False,
  ensure_ascii = True,
  check_circular = True,
  allow_nan = True,
  cls = None,
  indent = None,
  separators = None,
  encoding = 'utf-8',
  kw 
)

Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
``.write()``-supporting file-like object).

If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
(``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) 
will be skipped instead of raising a ``TypeError``.

If ``ensure_ascii`` is ``False``, then the some chunks written to ``fp``
may be ``unicode`` instances, subject to normal Python ``str`` to
``unicode`` coercion rules. Unless ``fp.write()`` explicitly
understands ``unicode`` (as in ``codecs.getwriter()``) this is likely
to cause an error.

If ``check_circular`` is ``False``, then the circular reference check
for container types will be skipped and a circular reference will
result in an ``OverflowError`` (or worse).

If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to
serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``)
in strict compliance of the JSON specification, instead of using the
JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).

If ``indent`` is a non-negative integer, then JSON array elements and object
members will be pretty-printed with that indent level. An indent level
of 0 will only insert newlines. ``None`` is the most compact representation.

If ``separators`` is an ``(item_separator, dict_separator)`` tuple
then it will be used instead of the default ``(', ', ': ')`` separators.
``(',', ':')`` is the most compact JSON representation.

``encoding`` is the character encoding for str instances, default is UTF-8.

To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
``.default()`` method to serialize additional types), specify it with
the ``cls`` kwarg.

Definition at line 108 of file __init__.py.

def simplejson::dumps (   obj,
  skipkeys = False,
  ensure_ascii = True,
  check_circular = True,
  allow_nan = True,
  cls = None,
  indent = None,
  separators = None,
  encoding = 'utf-8',
  kw 
)

Serialize ``obj`` to a JSON formatted ``str``.

If ``skipkeys`` is ``True`` then ``dict`` keys that are not basic types
(``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) 
will be skipped instead of raising a ``TypeError``.

If ``ensure_ascii`` is ``False``, then the return value will be a
``unicode`` instance subject to normal Python ``str`` to ``unicode``
coercion rules instead of being escaped to an ASCII ``str``.

If ``check_circular`` is ``False``, then the circular reference check
for container types will be skipped and a circular reference will
result in an ``OverflowError`` (or worse).

If ``allow_nan`` is ``False``, then it will be a ``ValueError`` to
serialize out of range ``float`` values (``nan``, ``inf``, ``-inf``) in
strict compliance of the JSON specification, instead of using the
JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).

If ``indent`` is a non-negative integer, then JSON array elements and
object members will be pretty-printed with that indent level. An indent
level of 0 will only insert newlines. ``None`` is the most compact
representation.

If ``separators`` is an ``(item_separator, dict_separator)`` tuple
then it will be used instead of the default ``(', ', ': ')`` separators.
``(',', ':')`` is the most compact JSON representation.

``encoding`` is the character encoding for str instances, default is UTF-8.

To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
``.default()`` method to serialize additional types), specify it with
the ``cls`` kwarg.

Definition at line 166 of file __init__.py.

def simplejson::load (   fp,
  encoding = None,
  cls = None,
  object_hook = None,
  kw 
)

Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
a JSON document) to a Python object.

If the contents of ``fp`` is encoded with an ASCII based encoding other
than utf-8 (e.g. latin-1), then an appropriate ``encoding`` name must
be specified. Encodings that are not ASCII based (such as UCS-2) are
not allowed, and should be wrapped with
``codecs.getreader(fp)(encoding)``, or simply decoded to a ``unicode``
object and passed to ``loads()``

``object_hook`` is an optional function that will be called with the
result of any object literal decode (a ``dict``). The return value of
``object_hook`` will be used instead of the ``dict``. This feature
can be used to implement custom decoders (e.g. JSON-RPC class hinting).

To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
kwarg.

Definition at line 220 of file __init__.py.

def simplejson::loads (   s,
  encoding = None,
  cls = None,
  object_hook = None,
  kw 
)

Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON
document) to a Python object.

If ``s`` is a ``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 specified. Encodings that are not ASCII based (such as UCS-2)
are not allowed and should be decoded to ``unicode`` first.

``object_hook`` is an optional function that will be called with the
result of any object literal decode (a ``dict``). The return value of
``object_hook`` will be used instead of the ``dict``. This feature
can be used to implement custom decoders (e.g. JSON-RPC class hinting).

To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
kwarg.

Definition at line 243 of file __init__.py.

def simplejson::read (   s  ) 

json-py API compatibility hook. Use loads(s) instead.

Definition at line 269 of file __init__.py.

def simplejson::write (   obj  ) 

json-py API compatibility hook. Use dumps(s) instead.

Definition at line 278 of file __init__.py.


Variable Documentation

Initial value:

[
    'dump', 'dumps', 'load', 'loads',
    'JSONDecoder', 'JSONEncoder',
]

Definition at line 90 of file __init__.py.

string simplejson::__version__ = '1.7.4'

Definition at line 89 of file __init__.py.

tuple simplejson::_default_decoder = JSONDecoder(encoding=None, object_hook=None)

Definition at line 218 of file __init__.py.

Initial value:

JSONEncoder(
    skipkeys=False,
    ensure_ascii=True,
    check_circular=True,
    allow_nan=True,
    indent=None,
    separators=None,
    encoding='utf-8'
)

Definition at line 98 of file __init__.py.


Generated on Sun Mar 18 07:15:45 2012 for Semantic MediaWiki by  doxygen 1.5.6