Home / Function/ JsonFormatter() — supabase Function Reference

JsonFormatter() — supabase Function Reference

Architecture documentation for the JsonFormatter() function in JsonFormatter.tsx from the supabase codebase.

Entity Profile

Relationship Graph

Source Code

apps/studio/components/grid/components/formatter/JsonFormatter.tsx lines 8–26

export const JsonFormatter = (p: PropsWithChildren<RenderCellProps<SupaRow, unknown>>) => {
  let value = p.row[p.column.key]

  if (value === null) return <NullValue />
  if (value === '') return <EmptyValue />

  // [Joshen] With reference to table-rows-query, we're only pulling max n characters on text/jsonb columns
  // If column value is longer, value will be concatenated with ..., and we just want to make sure the JSON
  // still renders seemingly like JSON in the grid
  const isTruncated = typeof value === 'string' && value.endsWith('...')
  if (isTruncated) return <>{value}</>

  try {
    const jsonValue = JSON.parse(value)
    return <>{JSON.stringify(jsonValue)}</>
  } catch (err) {
    return <>{JSON.stringify(value)}</>
  }
}

Subdomains

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free