Example #1
0
def jsonify(obj, **kwargs):
    indent = None
    if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] \
            and not request.is_xhr:
        indent = 2

    if hasattr(obj, 'to_json'):
        response = current_app.response_class(obj.to_json(indent=indent),
                                              mimetype='application/json')
    else:
        response = base_jsonify(obj, **kwargs)

    return response
Example #2
0
def jsonify(obj, **kwargs):
    indent = None
    if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] \
            and not request.is_xhr:
        indent = 2

    if hasattr(obj, 'to_json'):
        response = current_app.response_class(
            obj.to_json(indent=indent),
            mimetype='application/json'
        )
    else:
        response = base_jsonify(obj, **kwargs)

    return response
Example #3
0
def jsonify(obj, **kwargs):
    indent = None
    if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] \
            and not request.is_xhr:
        indent = 2

    if hasattr(obj, 'to_json'):
        response = Response(obj.to_json(indent=indent),
                            mimetype='application/json',
                            **kwargs)
    elif isinstance(obj, list):
        response = Response(json.dumps(obj, indent=indent),
                            mimetype='application/json',
                            **kwargs)
    else:
        response = base_jsonify(obj, **kwargs)

    return response
Example #4
0
def jsonify(obj, **kwargs):
    indent = None
    if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] \
            and not request.is_xhr:
        indent = 2

    if hasattr(obj, 'to_json'):
        response = Response(obj.to_json(indent=indent),
                            mimetype='application/json',
                            **kwargs)
    elif isinstance(obj, list):
        response = Response(json.dumps(obj, indent=indent),
                            mimetype='application/json',
                            **kwargs)
    else:
        response = base_jsonify(obj, **kwargs)

    return response