How can I use the same render cache but for json?
You have to use a cacheable response and then you can add cacheable metadata from a render array or from an object directly:

use Drupal\Core\Cache\CacheableJsonResponse;
use Drupal\Core\Cache\CacheableMetadata;

  $response = new CacheableJsonResponse($json, 200);

  $response-&gt;addCacheableDependency(CacheableMetadata::createFromRenderArray($content));

  $response-&gt;addCacheableDependency($entity);


If you use the core REST API this should already be implemented.