All Samples(160) | Call(40) | Derive(92) | Import(28)
Extensible JSON <http://json.org> encoder for Python data structures. Supports the following objects and types by default: +-------------------+---------------+ | Python | JSON | +===================+===============+ | dict | object | +-------------------+---------------+ | list, tuple | array | +-------------------+---------------+ | str, unicode | string | +-------------------+---------------+ | int, long, float | number | +-------------------+---------------+ | True | true | +-------------------+---------------+ | False | false | +-------------------+---------------+ | None | null | +-------------------+---------------+ To extend this to recognize other objects, subclass and implement a ``.default()`` method with another method that returns a serializable object for ``o`` if possible, otherwise it should call the superclass implementation (to raise ``TypeError``).
src/p/y/PyAMF-HEAD/doc/tutorials/examples/actionscript/google_appengine/simplejson/tests/test_unicode.py PyAMF(Download)
def test_encoding1():
encoder = S.JSONEncoder(encoding='utf-8')
u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
s = u.encode('utf-8')
ju = encoder.encode(u)
js = encoder.encode(s)
assert ju == js
src/z/3/z3ext-HEAD/sources/z3ext.content.attachment/trunk/src/z3ext/content/attachment/browser/jsapi.py z3ext(Download)
$Id: jsapi.py 11599 2010-01-15 15:39:32Z fafhrd91 $ """ import os.path from simplejson import JSONEncoder import transaction from zope import interface, event
class Encoder(JSONEncoder):
def encode(self, *kv, **kw):
return unicode(super(Encoder, self).encode(*kv, **kw))
encoder = JSONEncoder()
src/z/3/z3ext-HEAD/Sandbox/bubenkoff/z3ext-dev/z3ext/z3ext.widget.tinymce/trunk/src/z3ext/widget/tinymce/attachments.py z3ext(Download)
"""Adapter to get the image list for an object - these are returned to the tiny widget for insertion in the document This is based on z3ext.content.attachment.browser.jsapy """ from simplejson import JSONEncoder
from z3ext.content.attachment.interfaces import IImage, IAttachmentsExtension, ILink, IFile encoder = JSONEncoder() class ImageList(BrowserPage):
src/z/3/z3ext-HEAD/Sandbox/fafhrd91/oldcode/z3ext.tagcloud/trunk/src/z3ext/tagcloud/browser/tagslist.py z3ext(Download)
# -*- coding: utf-8 -*- # -*- Mode: Python; py-indent-offset: 4 -*- # * Author: Nikolay Kim <fafhrd91@gmail.com> from simplejson import JSONEncoder from zope.component import queryUtility from z3ext.tagcloud.interfaces import ITagCloud encoder = JSONEncoder()
src/z/3/z3ext-HEAD/Sandbox/sources/z3ext.portlets.livesearch/trunk/src/z3ext/portlets/livesearch/search.py z3ext(Download)
$Id: search.py 9630 2009-08-10 12:25:39Z fafhrd91 $ """ from simplejson import JSONEncoder from zope.component import queryUtility, queryMultiAdapter from zope.app.component.hooks import getSite from zope.traversing.browser import absoluteURL
from interfaces import _ encoder = JSONEncoder() class Search(object):
src/z/3/z3ext-HEAD/Sandbox/fafhrd91/oldcode/z3ext.principalfield/trunk/src/z3ext/principalfield/json.py z3ext(Download)
# -*- coding: utf-8 -*- # -*- Mode: Python; py-indent-offset: 4 -*- # * Author: Nikolay Kim <fafhrd91@gmail.com> from simplejson import JSONEncoder encoder = JSONEncoder()
src/z/3/z3ext-HEAD/sources/z3ext.widget.tinymce/trunk/src/z3ext/widget/tinymce/attachments.py z3ext(Download)
"""Adapter to get the image list for an object - these are returned to the tiny widget for insertion in the document This is based on z3ext.content.attachment.browser.jsapy """ from simplejson import JSONEncoder
from z3ext.content.attachment.interfaces import IImage, IAttachmentsExtension, ILink, IFile encoder = JSONEncoder() class ImageList(BrowserPage):
src/h/o/howl-HEAD/howl/cherrypy_tools.py howl(Download)
import simplejson import howl.error as error json_encoder = simplejson.JSONEncoder() mime_types = ["application/json"]
src/z/3/z3ext.content.attachment-1.3.4/src/z3ext/content/attachment/browser/jsapi.py z3ext.content.attachment(Download)
$Id: jsapi.py 11450 2009-11-30 19:53:20Z fafhrd91 $ """ import os.path from simplejson import JSONEncoder import transaction from zope import interface, event
class Encoder(JSONEncoder):
def encode(self, *kv, **kw):
return unicode(super(Encoder, self).encode(*kv, **kw))
encoder = JSONEncoder()
src/z/3/z3ext.widget.tinymce-0.2.0/src/z3ext/widget/tinymce/attachments.py z3ext.widget.tinymce(Download)
"""Adapter to get the image list for an object - these are returned to the tiny widget for insertion in the document This is based on z3ext.content.attachment.browser.jsapy """ from simplejson import JSONEncoder
from z3ext.content.attachment.interfaces import IImage, IAttachmentsExtension, ILink, IFile encoder = JSONEncoder() class ImageList(BrowserPage):
1 | 2 | 3 | 4 Next