I'm trying to make an API from a module i wrote. But how can i get my data from the database to json format?
I would highly recommend the API module as it takes care of all of this for you (including authentication).
https://pyrocms.com/pro (unlimited licensing for everything)
http://store.pyrocms.com/api-module.html (one license for just the API module)