How to update the node status? I'm using data from JSON to create new nodes or update fields on existing if node exist on my Drupal 8 website. So, when I use method to update nodes, I need to save in array node id of updated nodes and keys of fields with changed values in this node.

After update is finished I need to print table with all nodes of this content type where fields of updated nodes need to have different style (color, background, etc).

So if my old node have 
body = "body1" and description  = "description 1" and new node have body = "body2"and description  = "description 1" after update is finished i need to get output like this:



Here is an example:

$node = \Drupal\node\Entity\Node::load($nid);
$node-&gt;set("body", 'New body text');
$node-&gt;set("description", 'New value');
$node-&gt;save();


Any suggestion?

Note: when I use $node-&gt;save(); if all updated values is same nothing is changed (date of node in content from admin panel is same as before update), but if values is different I need to store node id, keys and values only of changed fields in array.
To set the status you can use the setPublished() method:


  public function Node::setPublished
  
  Sets the published status of a node..
  
  Parameters
  
  bool $published: TRUE to set this node to published, FALSE to set it
  to unpublished.


In your case:

$node = \Drupal\node\Entity\Node::load($nid);
$node-&gt;set("body", 'New body text');
$node-&gt;set("field_name", 'New value');
$node-&gt;setPublished(TRUE);