converts tables to json and json to tables