title: 422 error trying to save json data to the database
body: <p>I'm trying to save data to my MySql db from a Node method. This includes a field called <code>attachments</code>.</p>
  <p><code>console.log(JSON.stringify(post.acf.attachments[0]));</code> returns:</p>
  <pre><code>{
    &quot;ID&quot;: 4776,
    &quot;id&quot;: 4776,
    &quot;title&quot;: &quot;bla&quot;,
    &quot;filename&quot;: &quot;bla.pdf&quot;,
    &quot;filesize&quot;: 1242207,
    &quot;url&quot;: &quot;https://example.com/wp-content/uploads/bla.pdf&quot;,
    &quot;link&quot;: &quot;https://example.com/bla/&quot;,
    &quot;alt&quot;: &quot;&quot;,
    &quot;author&quot;: &quot;1&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;caption&quot;: &quot;&quot;,
    &quot;name&quot;: &quot;bla&quot;,
    &quot;status&quot;: &quot;inherit&quot;,
    &quot;uploaded_to&quot;: 0,
    &quot;date&quot;: &quot;2020-10-23 18:05:13&quot;,
    &quot;modified&quot;: &quot;2020-10-23 18:05:13&quot;,
    &quot;menu_order&quot;: 0,
    &quot;mime_type&quot;: &quot;application/pdf&quot;,
    &quot;type&quot;: &quot;application&quot;,
    &quot;subtype&quot;: &quot;pdf&quot;,
    &quot;icon&quot;: &quot;https://example.com/wp-includes/images/media/document.png&quot;
  }
  </code></pre>
  <p>This is indeed the data I want to save to the db:</p>
  <pre><code>await existing_post.save({
      ...
      attachments: post.acf.attachments[0],
  )};
  </code></pre>
  <p>However, the attachments field produces a 422 server error (if I comment out this field, the other fields save without a problem to the db). I'm not getting what is causing this error. Any ideas?</p>
  <p>I've also tried</p>
  <pre><code>await existing_post.save({
      ...
      attachments: post.acf.attachments,
  )};
  </code></pre>
  <p>but then it seems to just save <code>&quot;[object Object]&quot;</code> to the database.</p>
  <p>The field in the database is defined as text. I've also tried it by defining the field as json, but that made no difference.</p>
  <pre><code>exports.up = function (knex, Promise) {
      return knex.schema.table(&quot;posts&quot;, function (table) {
          table.longtext(&quot;attachments&quot;);
      });
  };
  </code></pre>