Moved x_to_json functions to methods in the dbic classes