title: Drupal 8 Serialization and Deserialization
body: <p>I am attempting to serialize a Node in Drupal 8. The serialization to JSON works and the output is readable and makes sense, but I am unable to deserialize it. Code is below:</p>
  
  <pre><code>    $entityManager = new EntityManager();
      $encoders = array(new JsonEncoder());
      $normalizers = array(
        new EntityNormalizer($entityManager),
        new TypedDataNormalizer($entityManager)
      );
      $serializer = new Serializer($normalizers, $encoders);
      $serialized_entity = $serializer-&gt;serialize($entity, 'json');
      $node = $serializer-&gt;deserialize($serialized_entity, '\Drupal\node\Entity\Node', 'json');
  </code></pre>
  
  <p>The truncated error is below:</p>
  
  <pre><code>    Error: Call to a member function get() on null in Drupal\Core\Entity\EntityManager-&gt;getEntityTypeFromClass() (line 377 of /vagrant/drupal-8.2.1/core/lib/Drupal/Core/Entity/EntityManager.php) #0 /vagrant/drupal-8.2.1/core/modules/serialization/src/Normalizer/EntityNormalizer.php(43): Drupal\Core\Entity\EntityManager-&gt;getEntityTypeFromClass('\\Drupal\\node\\En...') #1
  </code></pre>
  
  <p>A little background, I am trying to use this in an insert hook to serialize the node and send it to an endpoint, where I want to deserialize it. Any help is greatly appreciated. Thanks.</p>