wrapped scala toJSON in sql.py