'Render data as JSON'

def render_json(self, data):

    class NoFailEncoder(JSONEncoder, ):
        def default(self, obj):
            if isinstance(obj, (list, dict, str, unicode, int, float, bool, type(None))):
                return JSONEncoder.default(self, obj)
            else:
                return json_helper(obj)
    return json.dumps(data, indent=1, cls=NoFailEncoder, sort_keys=True, allow_nan=False)
