• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(337)  |  Call(320)  |  Derive(0)  |  Import(17)
Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
a JSON document) to a Python object.

*encoding* determines the encoding used to interpret any
:class:`str` objects decoded by this instance (``'utf-8'`` by
default).  It has no effect when decoding :class:`unicode` objects.

Note that currently only encodings that are a superset of ASCII work,
strings of other encodings should be passed in as :class:`unicode`.

*object_hook*, if specified, will be called with the result of every
JSON object decoded and its return value will be used in place of the
given :class:`dict`.  This can be used to provide custom
deserializations (e.g. to support JSON-RPC class hinting).

*object_pairs_hook* is an optional function that will be called with
the result of any object literal decode with an ordered list of pairs.
The return value of *object_pairs_hook* will be used instead of the
:class:`dict`.  This feature can be used to implement custom decoders
that rely on the order that the key and value pairs are decoded (for
example, :func:`collections.OrderedDict` will remember the order of
insertion). If *object_hook* is also defined, the *object_pairs_hook*
takes priority.

*parse_float*, if specified, will be called with the string of every
JSON float to be decoded.  By default, this is equivalent to
``float(num_str)``. This can be used to use another datatype or parser
for JSON floats (e.g. :class:`decimal.Decimal`).

*parse_int*, if specified, will be called with the string of every
JSON int to be decoded.  By default, this is equivalent to
``int(num_str)``.  This can be used to use another datatype or parser
for JSON integers (e.g. :class:`float`).

*parse_constant*, if specified, will be called with one of the
following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``.  This
can be used to raise an exception if invalid JSON numbers are
encountered.

If *use_decimal* is true (default: ``False``) then it implies
parse_float=decimal.Decimal for parity with ``dump``.

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

        def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None,
        parse_int=None, parse_constant=None, object_pairs_hook=None,
        use_decimal=False, **kw):
    """Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
    a JSON document) to a Python object.

    *encoding* determines the encoding used to interpret any
    :class:`str` objects decoded by this instance (``'utf-8'`` by
    default).  It has no effect when decoding :class:`unicode` objects.

    Note that currently only encodings that are a superset of ASCII work,
    strings of other encodings should be passed in as :class:`unicode`.

    *object_hook*, if specified, will be called with the result of every
    JSON object decoded and its return value will be used in place of the
    given :class:`dict`.  This can be used to provide custom
    deserializations (e.g. to support JSON-RPC class hinting).

    *object_pairs_hook* is an optional function that will be called with
    the result of any object literal decode with an ordered list of pairs.
    The return value of *object_pairs_hook* will be used instead of the
    :class:`dict`.  This feature can be used to implement custom decoders
    that rely on the order that the key and value pairs are decoded (for
    example, :func:`collections.OrderedDict` will remember the order of
    insertion). If *object_hook* is also defined, the *object_pairs_hook*
    takes priority.

    *parse_float*, if specified, will be called with the string of every
    JSON float to be decoded.  By default, this is equivalent to
    ``float(num_str)``. This can be used to use another datatype or parser
    for JSON floats (e.g. :class:`decimal.Decimal`).

    *parse_int*, if specified, will be called with the string of every
    JSON int to be decoded.  By default, this is equivalent to
    ``int(num_str)``.  This can be used to use another datatype or parser
    for JSON integers (e.g. :class:`float`).

    *parse_constant*, if specified, will be called with one of the
    following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``.  This
    can be used to raise an exception if invalid JSON numbers are
    encountered.

    If *use_decimal* is true (default: ``False``) then it implies
    parse_float=decimal.Decimal for parity with ``dump``.

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

    """
    return loads(fp.read(),
        encoding=encoding, cls=cls, object_hook=object_hook,
        parse_float=parse_float, parse_int=parse_int,
        parse_constant=parse_constant, object_pairs_hook=object_pairs_hook,
        use_decimal=use_decimal, **kw)
        


src/m/a/mandible-HEAD/example/simplejson/tool.py   mandible(Download)
    else:
        raise SystemExit(sys.argv[0] + " [infile [outfile]]")
    try:
        obj = json.load(infile,
                        object_pairs_hook=json.OrderedDict,
                        use_decimal=True)
    except ValueError, e:

src/p/y/python-enunciate-samples-HEAD/identity.py   python-enunciate-samples(Download)
def parse(input):
    """Parse specified file or string and return an Identity object created from it."""
    if hasattr(input, "read"):
        data = json.load(input)
    else:
        data = json.loads(input)
    return Identity(data)

src/p/y/python-enunciate-samples-HEAD/familytree.py   python-enunciate-samples(Download)
def parse(input):
    """Parse specified file or string and return a FamilyTree object created from it."""
    if hasattr(input, "read"):
        data = json.load(input)
    else:
        data = json.loads(input)
    return FamilyTree(data)

src/p/y/pygtkhelpers-0.4.2/examples/addressbook/person.py   pygtkhelpers(Download)
def from_json(file):
    with open(file) as inf:
        data = json.load(inf)
    for item in data:
        yield Person(item['name'], item['surname'], item['email'])
 

src/j/s/jsonschema-HEAD/examples/sample_override.py   jsonschema(Download)
  else:
    raise SystemExit("%s [infile [schemafile]]" % (sys.argv[0],))
  try:
    obj = simplejson.load(infile)
    schema = simplejson.load(schemafile)
    jsonschema.validate(obj, schema, validator_cls=FunctionValidator)
  except ValueError, e:

src/j/s/jsonical-HEAD/jsonical.py   jsonical(Download)
def load(fp):
    return json.load(fp, cls=Decoder, parse_float=decimal.Decimal)
 
def loads(s):
    return json.loads(s, cls=Decoder, parse_float=decimal.Decimal)
 
def tool():

src/j/s/jsonical-0.0.4/jsonical.py   jsonical(Download)
def load(fp):
    return json.load(fp, cls=Decoder, parse_float=decimal.Decimal)
 
def loads(s):
    return json.loads(s, cls=Decoder, parse_float=decimal.Decimal)
 
def tool():

src/p/y/python-amazon-product-api-HEAD/examples/json-results.py   python-amazon-product-api(Download)
                if parent == 'Error':
                    raise AWSError(children['Code'], children['Message'])
                _find_errors(children)
        parsed = simplejson.load(fp)
        _find_errors(parsed)
        return parsed
 

src/g/e/geojson-1.0.1/geojson/codec.py   geojson(Download)
def load(fp, cls=simplejson.JSONDecoder, object_hook=None, **kwargs):
    return simplejson.load(fp, cls=cls, object_hook=object_hook, **kwargs)
 
 
def loads(s, cls=simplejson.JSONDecoder, object_hook=None, **kwargs):
    return simplejson.loads(s, cls=cls, object_hook=object_hook, **kwargs)
 

src/d/j/django-roa-1.6/examples/twitter_roa/serializers.py   django-roa(Download)
    else:
        stream = stream_or_string
    models.get_apps()
    object_list = simplejson.load(stream)
    if not isinstance(object_list, list):
        object_list = [object_list]
    for obj in object_list:

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next