I haven't actually messed with the Postgres JSON type much. IMO it makes more sense to use straight-up dict() within Python and when stored to the database, then let Flask jsonify the dict() if it needs to leave the server context.
Usage:
You have to tell Postgres to use the HSTORE extension for your database. It's shipped with 9.3 but not active by default.
Then for SQLAlchemy you'd add something like this in your models.py:
from sqlalchemy.dialects.postgresql import HSTORE
from sqlalchemy.ext.mutable import MutableDict
class Widget(db.Model):
id = db.Column(db.Integer, primary_key=True)
data = db.Column(MutableDict.as_mutable(HSTORE))
You don't technically have to do the MutableDict stuff to use HSTORE, but it's handy. They're mutable on the Python side already, so why not be consistent. With the rest of the model as appropriate (init, repr), and I'm using Flask-SQLAlchemy which makes the contexts line up and such.It's nice because it's an RDB field so you can do all the usual Postgres love when you're not wanting to store a dict(). Or you can just do a table with id, data, and id can even be a kv-style key if you want some sort of meaning attached to the primkey. Plus it's dicts, and Python is heavy on the dicts, and it's a quick leap from there to JSON.