title: Cast all columns of numeric type to text when converting a row to json
body: <p>I have table with <code>numeric/decimal</code> columns and I am converting the rows to json</p>
  <pre class="lang-sql prettyprint-override"><code>select to_jsonb(t.*) from my_table t
  </code></pre>
  <p>I need to have the <code>numeric</code> columns casted to text before converted to json.</p>
  <p><em>The reason why I need this is JavaScript don't handle really big numbers well so I may loose a precision. I use <code>decimal.js</code> and the string representation is best to construct the <code>decimal.js</code> number from.</em></p>
  <p>I know I can do this</p>
  <pre class="lang-sql prettyprint-override"><code>select to_jsonb(t.*) || jsonb_build_object('numeric_column', numeric_column::text) from my_table t
  </code></pre>
  <p>But I want to have it done automatically. Is there a way to somehow cast all <code>numeric</code> columns to text before passing to <code>to_jsonb</code> function?</p>
  <p>It can be user-defined postgres function.</p>
  <p><strong>EDIT</strong>: Just to clarify my question. What I need is some function similar to <code>to_jsonb</code> except all columns of the type <code>numeric/decimal</code> are stored as <code>string</code> in the resulting JSON.</p>
  <p>Thanks</p>