This question has been answered by BobRay. See the first response.
$template = $resource->get('template');
$docId - $resource->get('id');
if ( ($docId != 23) || ($template != 123)) {
return '';
}
$alias = $resource->get('alias');
/* {"name": "[[*pagetitle]]", "another_key": "[[*myfirstTV]]", "another_key2": "[[*mysecondTV]]"} */
$data = array(
'name' => $resource->get('pagetitle'),
'another_key' => $resource->getTVVAlue('myfirstTV'),
'another_key2' => $resource->getTVValue('mysecondTV'),
);
$jsonData = $modx->toJSON($data);
$file = MODX_ASSETS_PATH . 'hotels/' . $alias . '.json';
$fp = fopen($file, 'w');
if ($fp) {
fwrite($fp, $jsondata);
fclose($fp);
} else {
$modx->log(modX::LOG_LEVEL_ERROR, 'Could not open File: ' . $file);
}
return '';