Skip to content

jsonify compatibility #62

Closed
Closed
@hut8

Description

@hut8

I've been playing around with Flask and MongoDB today and really like them. Thanks very much for making integrating Flask with PyMongo easier.

I'm really surprised at how hard it is to return JSON from a view method, considering that's the first thing I tried and really only thing I want to do for this project. If this is integrating PyMongo and Flask, shouldn't there be an equivalent to flask.jsonify() that works with BSON?

As you probably know, this won't work because jsonify can't deal with ObjectId:

@app.route('/search/<query>')
def search(query):
    events = mongo.db.contributions.find({
        '_user_lower' : query.lower()
    })
    events = { 'events': list(events) }
    return jsonify(**events)

Akhenakh's awesome gist is working for me right now, but it seems like pymongo should offer this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions