def __init__(self, object, fields=(), custom_fields=False, status=200):

        # Perform JSON serialization
        emitter = JSONEmitter(object, {}, None, fields=fields, custom_fields=custom_fields)
        content = emitter.render()

        # Return response with correct payload/type
        super(JsonResponse, self).__init__(content, status=status, mimetype="application/json")
 def __init__(self, object):
     
     # Perform JSON serialization
     emitter = JSONEmitter(object, {}, None)
     content = emitter.render()
     
     # Return response with correct payload/type
     super(JsonResponse, self).__init__(content, mimetype='application/json')
Example #3
0
 def __init__(self, object, **kwargs):
     
     # Perform JSON serialization
     emitter = JSONEmitter(object, {}, None)
     content = emitter.render()
     status_code = kwargs.get('status', 200)
     
     # Return response with correct payload/type
     super(JsonResponse, self).__init__(content, mimetype='application/json', status=status_code)
Example #4
0
    def __init__(self, object):

        # Perform JSON serialization
        emitter = JSONEmitter(object, {}, None)
        content = emitter.render()

        # Return response with correct payload/type
        super(JsonResponse, self).__init__(content,
                                           mimetype='application/json')
Example #5
0
    def __init__(self, object=None, **kwargs):

        # Perform JSON serialization
        if object is not None:
            emitter = JSONEmitter(object, {}, None, version=kwargs.get('version', None))
            content = emitter.render()
        else:
            content = ''

        # Status code for the response
        status_code = kwargs.get('status', 200)

        # Return response with correct payload/type
        super(JsonResponse, self).__init__(content, content_type='application/json; charset=%s' % settings.DEFAULT_CHARSET, status=status_code)
    def __init__(self, object=None, **kwargs):

        # Perform JSON serialization
        if object is not None:
            emitter = JSONEmitter(object, {},
                                  None,
                                  version=kwargs.get('version', None))
            content = emitter.render()
        else:
            content = ''

        # Status code for the response
        status_code = kwargs.get('status', 200)

        # Return response with correct payload/type
        super(JsonResponse,
              self).__init__(content,
                             content_type='application/json; charset=%s' %
                             settings.DEFAULT_CHARSET,
                             status=status_code)