from sqlalchemy.dialects.postgres import JSON
from sqlalchemy.sql.expression import cast
db_session.query(Resource).filter(Resources.data['lastname'] == cast('Doe',
    JSON)).all()
Python SQLAlchemy and Postgres - How to query a JSON element