title: Is there a way to customize JSON serialization when inserting/updating a model in Laravel?
body: <p>I have a model with some json columns. In my seeder, I got something like this: </p>
  
  <pre class="lang-php prettyprint-override"><code>/* dd($object)
  {
      'string_field1': "áéíóúÁÉÍÓÚñÑ",
      'string_field2': "123",
      'string_field3': "Normal string",
  }
  */
  MyModel::create([
     'json_column1' =&gt; ["{$object-&gt;string_attribute1} - {$object-&gt;string_attribute2}"],
     'json_column2' =&gt; [$object-&gt;string_attribute3],
  ]);
  </code></pre>
  
  <p>My model has the json columns in its casts array</p>
  
  <pre class="lang-php prettyprint-override"><code># MyModel.php
  protected $casts = [
      'json_column1' =&gt; 'array',
      'json_column2' =&gt; 'array'
  ];
  </code></pre>
  
  <p>When I look at the records inserted in the database (PostgreSQL), I see two problems. </p>
  
  <ul>
  <li>Their values look like arrays</li>
  <li>All unicode characters are escaped</li>
  </ul>
  
  <p>Basically, it's using the <code>json_encode()</code> function under the hood with no options and I'd like to pass some options (<code>JSON_FORCE_OBJECT</code> and <code>JSON_UNESCAPED_UNICODE</code>) by default without having to explicitly write it every time.</p>
  
  <h1><b>TL;DR</b></h1>
  
  <pre class="lang-php prettyprint-override"><code>// this
  MyModel::create([
     'json_column1' =&gt; ["{$object-&gt;string_attribute1} - {$object-&gt;string_attribute2}"],
     'json_column2' =&gt; [$object-&gt;string_attribute3],
  ]);
  // automagically converts to this
  MyModel::create([
     'json_column1' =&gt; json_encode(["{$object-&gt;string_attribute1} - {$object-&gt;string_attribute2}"]),
     'json_column2' =&gt; json_encode([$object-&gt;string_attribute3]),
  ]);
  // but I want it to convert to this
  MyModel::create([
     'json_column1' =&gt; json_encode(["{$object-&gt;string_attribute1} - {$object-&gt;string_attribute2}"], JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE),
     'json_column2' =&gt; json_encode([$object-&gt;string_attribute3], JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE),
  ]);
  </code></pre>