Exract all node field values to json including reference entities with value
If you really really want to do this which you probably wont with JSON API Views and
serialisation
https://www.drupal.org/docs/8/api/serialization-api/serialization-api-overview
eg:
dump(Drupal::service('serializer')-&gt;serializer-&gt;serialize($entity, 'json'));

But if you really want to ...
$node = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;load($nid);
$data = [];
foreach ($node-&gt;getFields() as $name =&gt; $field) {
   // Get Type.
   $field_type = $node-&gt;get($name)-&gt;getFieldDefinition()-&gt;getType();
   //see https://drupal.stackexchange.com/questions/180373/how-to-get-the-list-of-field-types

   switch($field_type) {
      case 'text_with_summary':
      case 'text':
      case 'text_long: 
        $data[$name]  = $field-&gt;getString();
        break;
      case 'entity_reference':
      case 'entity_reference':
        $value = [];
        $items = $field-&gt;referencedEntities();
        if (!empty($items)) {
            foreach ($items as $item) {
                // here is the crappy part 
                $val_1 = $item-&gt;get('field_something')-&gt;value;
                $value[$item-&gt;id()] =  $val_1,
            }
        }
        $data[$name] = $value;
      break;
      // continue for other data types
      // and set a default !
   }
}