Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
Json does not handle encodings, so we need to convert any strings
in unicode in a way which allows to convert it back on the receiver.

        def decode_for_json(value, additional_encodings=[]):
    """ Json does not handle encodings, so we need to convert any strings
    in unicode in a way which allows to convert it back on the receiver.
    if additional_encodings:
        encodings = list(EXPECTED_ENCODINGS) + list(additional_encodings)
        encodings = EXPECTED_ENCODINGS

    # OOBTree
    if isinstance(value, OOBTree):
        value = {'publisher-wrapper': True,
                 'type': 'OOBTree',
                 'value': dict(value)}

    # PortletAssignmentSettings
    if isinstance(value, PortletAssignmentSettings):
        value = {'publisher-wrapper': True,
                 'type': 'PortletAssignmentSettings',
                 'value': dict(value.data)}

    # unicode
    if isinstance(value, unicode):
        return u'unicode:' + value

    # encoded strings
    elif isinstance(value, str):
        for enc in encodings:
                return unicode(enc) + u':' + value.decode(enc)
            except UnicodeDecodeError:

    # lists, tuples, sets
    elif isinstance(value, (list, tuple, set)):
        nval = []
        for sval in value:
        return nval

    # dicts
    elif isinstance(value, dict):
        nval = {}
        for key, sval in value.items():
            key = decode_for_json(key)
            sval = decode_for_json(sval)
            nval[key] = sval
        return nval

    # python datetime
    elif isinstance(value, datetime):
        return {'publisher-wrapper': True,
                'type': 'datetime',
                'value': value.strftime(ISOFORMAT)}

    # zope datetime
    elif isinstance(value, DateTime):
        return {'publisher-wrapper': True,
                'type': 'DateTime',
                'value': str(value)}

    # others
        return value

src/f/t/ftw.publisher.sender-2.2.0/ftw/publisher/sender/extractor.py   ftw.publisher.sender(Download)
from AccessControl.SecurityInfo import ClassSecurityInformation
from Products.CMFPlone.interfaces import IPloneSiteRoot
from ZODB.POSException import ConflictError
from ftw.publisher.core.interfaces import IDataCollector
from ftw.publisher.core.utils import decode_for_json
        @rtype:         string
        data = decode_for_json(data)
        return json.dumps(data, sort_keys=True)

src/f/t/ftw.publisher.core-2.4.0/ftw/publisher/core/tests/test_utils.py   ftw.publisher.core(Download)
        transport_data = json.dumps(utils.decode_for_json(data))
        result_data = utils.encode_after_json(json.loads(transport_data))
        return result_data

src/f/t/ftw.publisher.core-2.4.0/ftw/publisher/core/tests/test_portlet_adapter.py   ftw.publisher.core(Download)
        getterdata = adapter.getData()
        getterdata = utils.decode_for_json(getterdata)
        jsondata = json.dumps(getterdata)

src/f/t/ftw.publisher.core-2.4.0/ftw/publisher/core/tests/test_dexterity.py   ftw.publisher.core(Download)
        if json:
            data = utils.decode_for_json(data)
            data = dumps(data)