Refactor json_to_table