title: How to serialize empty array to JSON object (curly braces) with JMS Serializer in Symfony
body: <p>Having the following PHP class</p>
  
  <pre><code>class SampleObject 
  {
      private $map;
  
      private $array;
  
      public function getMap(): array 
      {
          return $map;
      }
  
      public function setMap(array $map) 
      {
          $this-&gt;map = $map;
      }
  
      public function getArray(): array
      {
          return $this-&gt;array;
      }
  
      public function setArray(array $array) {
          $this-&gt;array = $array;
      }
  }
  </code></pre>
  
  <p>and two instances:</p>
  
  <pre><code>$inst1 = new SampleObject();
  $inst2 = new SampleObject();
  $inst1-&gt;setMap(['key' =&gt; 'value']);
  $inst1-&gt;setArray([1]);
  $inst2-&gt;setMap([]);
  $inst2-&gt;setArray([]);
  </code></pre>
  
  <p>When they are serialized with JMS Serializer to json, the first one becomes:</p>
  
  <pre><code>{"map": {"key": "value"}, "array": [1]}
  </code></pre>
  
  <p>and the second one:</p>
  
  <pre><code>{"map": [], "array": []}
  </code></pre>
  
  <p>How to force the serializer to serialize the second object as <code>{"map": {}, "array": []}</code>?</p>