Skip to content

pablosjv/mongo-flask-serializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mongo-flask-serializer

A serializer for MongoDB objects using flask and python.

When creating APIs with Flask and MongoDB, it can be very stressful to return a JSON response with a MongoDB objectID or datetime format. This python class handles that problem.

Requirements

  • flask

Usage

from flask import Flask
from serialize import Serializer

app = Flask(__name__)
ser = Serializer(app)

@app.route('/')
def serialize_test():
    """Testing the serializer."""
    test_json = {'id': ObjectId("58d8e4f9f2d63f0909523a7e"),
                 'Salute': 'Hey Whats up?',
                 'array': [1, 3, 4, 5]
                 }
    return ser.jsonify(test_json)

app.run(host='0.0.0.0', port=5006)

About

A serializer for MongoDB objects in flask responses

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages