Serializing a list of anvil.tables.Row objects

you might like this:

But otherwise, yeah - you’ll also have to do something similar for linked rows, since

rows = list(dict(r) for r in app_tables.my_table.search())

will only go one level deep…

To go a second level you could do something like:

def get_row_as_dict(row):
  return dict(row)

rows_as_dicts =[]
table_row_cols = ['column_w_table_row']
for row in app_tables.my_table.search():
  row_as_dict = get_row_as_dict(row)
  for col in table_row_cols:
    row_as_dict[col] = get_row_as_dict(row[col])
  rows_as_dicts.append(row_as_dict)
return rows_as_dicts

3 Likes