Skip to main content

Zope3 JSON base libraries

Project description

This package provides basic JSON components like JSON reader and writer utilities and a JSON-RPC client proxy including the transport implementation for Zope3.

Detailed Documentation

README

We can use the JSONReader and JSONWriter if we need to convert a data structure to or from JSON syntax – in other words a EcmaScript mapping object. Let’s check the utilities:

>>> import zope.component
>>> from z3c.json import interfaces
>>> from z3c.json import testing
>>> testing.setUpJSONConverter()

JSONWriter Utility

>>> jsonWriter = zope.component.getUtility(interfaces.IJSONWriter)
>>> jsonWriter
<z3c.json.converter.JSONWriter object at ...>

Read some data:

>>> input = {u'a': ['fred', 7],
...          u'b':['mary', 1.234]}
>>> jsonStr = jsonWriter.write(input)
>>> jsonStr
u'{"a":["fred",7],"b":["mary",1.234]}'

JSONReader Utility

>>> jsonReader = zope.component.getUtility(interfaces.IJSONReader)
>>> jsonReader
<z3c.json.converter.JSONReader object at ...>

Conver the data back to python:

>>> output = jsonReader.read(jsonStr)
>>> output
{u'a': [u'fred', 7], u'b': [u'mary', 1.234]}
>>> input == output
True

CHANGES

0.5.1 (2008-01-24)

  • Improved meta-data.

0.5.0 (2008-01-21)

  • Initial Release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

z3c.json-0.5.1.tar.gz (17.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page