Parse REST Json replay
Drupal has a service for serialisation, pre-configured with the normalisers and encoders you need. The error you currently have is because you're not setting up the instance of the serialiser with the Symfony\Component\Serializer\Encoder\JsonEncoder, but you'll also need, for example, the Drupal\serialization\Normalizer\ConfigEntityNormalizer normaliser.

This code works well for me:

$serializer = \Drupal::service('serializer');
$node = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;load(1);

$output = $serializer-&gt;serialize($node, 'json');
$deserialized_node = $serializer-&gt;deserialize($output, \Drupal\node\Entity\Node::class, 'json');


As always, inject the services if possible.