~ubuntu-branches/ubuntu/trusty/piston-mini-client/trusty-proposed

« back to all changes in this revision

Viewing changes to piston_mini_client/serializers.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-08-11 17:26:42 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110811172642-pwbja8hb8u0lvy16
Tags: 0.5+bzr41-0ubuntu1
new bzr snapshot that supports overriding the httplib2
signature checks

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
    'FormSerializer',
11
11
]
12
12
 
13
 
import simplejson
 
13
import json
14
14
import urllib
15
15
 
16
16
from piston_mini_client import PistonSerializable
20
20
 
21
21
    This is the default serializer for content type *application/json*.
22
22
    """
23
 
    class PistonSerializableEncoder(simplejson.JSONEncoder):
 
23
    class PistonSerializableEncoder(json.JSONEncoder):
24
24
        def default(self, o):
25
25
            if isinstance(o, PistonSerializable):
26
26
                return o._as_serializable()
27
 
            return simplejson.JSONEncoder.default(self, o)
 
27
            return json.JSONEncoder.default(self, o)
28
28
 
29
29
    def serialize(self, obj):
30
30
        """Serialize ``obj`` into JSON.
32
32
        As well as the usual basic JSON-encodable types, this serializer knows
33
33
        how to serialize ``PistonSerializable`` objects.
34
34
        """
35
 
        return simplejson.dumps(obj, cls=self.PistonSerializableEncoder)
 
35
        return json.dumps(obj, cls=self.PistonSerializableEncoder)
36
36
 
37
37
 
38
38
class FormSerializer(object):