title: How can I use doctrine embeddable with json column?
body: <p>In my Symfony project, I have a doctrine entity that contains a nested object. Like in the example below:</p>
  
  <pre><code>/**
   * @ORM\Entity(repositoryClass="App\Repository\EntityRepository")
   */
  class Enity
  {
      /**
       * @ORM\Id()
       *
       * @var int
       */
      private $id;
  
      /**
       * @ORM\Column(type="json")
       *
       * @var NestedObject
       */
      private $nestedObject;
  
      public function getNestedObject(): NestedObject
      {
          return $this-&gt;nestedObject;
      }
  
      public function setNestedObject(NestedObject $object): void
      {
          $this-&gt;nestedObject = $object;
      }
  }   
  </code></pre>
  
  <p>and nested object: </p>
  
  <pre><code>class NestedObject
  {
      /**
       * @var FirstOption
       */
      private $firstOption;
  
      /**
       * @var SecondOption
       */
      private $secondOption;
  
      /**
       * @return FirstOption
       */
      public function getFirstOption(): FirstOption
      {
          return $this-&gt;firstOption;
      }
  
      /**
       * @return SecondOption
       */
      public function getSecondOption(): SecondOption
      {
          return $this-&gt;secondOption;
      }
  }
  </code></pre>
  
  <p>I want to store the Nested Object in Postgres as jsonb, in such a way that the object is automatically serialized when saved and deserialized when fetched from the database.<br>
  I have read doctrine documentation and didn't find something about json and embeddable objects.  </p>
  
  <p>Is there any way to store embeddable objects as json structure without creating an extra column for any property? Or any alternative for convenient work with nested json objects?</p>