* and adds an application/json HTTP header to the output.
* After finishing the process is getting killed.
*
- * @param mixed $x The input content.
- * @param string $content_type Type of the input (Default: 'application/json').
+ * @param mixed $x The input content.
+ * @param string $content_type Type of the input (Default: 'application/json').
+ * @param integer $options JSON options
*/
- public static function jsonExit($x, $content_type = 'application/json') {
+ public static function jsonExit($x, $content_type = 'application/json', int $options = null) {
header("Content-type: $content_type");
- echo json_encode($x);
+ echo json_encode($x, $options);
exit();
}
use Friendica\BaseModule;
use Friendica\Core\Addon;
+use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Nodeinfo;
$nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true;
- header('Content-type: application/json; charset=utf-8');
- echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
- exit;
+ System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
}
use Friendica\BaseModule;
use Friendica\Core\Addon;
+use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Nodeinfo;
$nodeinfo['metadata']['explicitContent'] = $config->get('system', 'explicit_content', false) == true;
- header('Content-type: application/json; charset=utf-8');
- echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
- exit;
+ System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
}
use Friendica\BaseModule;
use Friendica\Core\Addon;
+use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Nodeinfo;
$nodeinfo['services']['inbound'][] = 'imap';
}
- header('Content-type: application/json; charset=utf-8');
- echo json_encode($nodeinfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
- exit;
+ System::jsonExit($nodeinfo, 'application/json; charset=utf-8', JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
}
}