'Returns a JSON string from the given data.
The data can be a nested structure of dict, list, str, unicode, bool, int, float and None.'

def dumps(self, obj, *args, **kwargs):

    if isinstance(obj, (str, unicode)):
        return self.encode(obj)
    if isinstance(obj, (int, long)):
        return str(obj)
    if isinstance(obj, float):
        return str(self.float(obj))
    if isinstance(obj, bool):
        return ((obj and 'true') or 'false')
    if isinstance(obj, type(None)):
        return 'null'
    if isinstance(obj, dict):
        return ('{%s}' % ',    '.join([('%s:    %s' % (self.encode(k), self.dumps(v))) for (k, v) in sorted(obj.items())]))
    if isinstance(obj, (list, tuple, GeneratorType)):
        return ('[%s]' % ',    '.join((self.dumps(v) for v in obj)))
    raise TypeError(("can't    process    %s." % type(obj)))
