How to serialize SqlAlchemy result to JSON?

后端 未结 27 1889
说谎
说谎 2020-11-22 09:59

Django has some good automatic serialization of ORM models returned from DB to JSON format.

How to serialize SQLAlchemy query result to JSON format?

I tried

27条回答
  •  不知归路
    2020-11-22 10:04

    It is not so straighforward. I wrote some code to do this. I'm still working on it, and it uses the MochiKit framework. It basically translates compound objects between Python and Javascript using a proxy and registered JSON converters.

    Browser side for database objects is db.js It needs the basic Python proxy source in proxy.js.

    On the Python side there is the base proxy module. Then finally the SqlAlchemy object encoder in webserver.py. It also depends on metadata extractors found in the models.py file.

提交回复
热议问题