Skip to content

Instantly share code, notes, and snippets.

@ryo88c
Created February 12, 2012 17:49
Show Gist options
  • Save ryo88c/1809886 to your computer and use it in GitHub Desktop.
Save ryo88c/1809886 to your computer and use it in GitHub Desktop.
結果を JSON として返すための output ハンドラ
<?php
/**
* JSON出力
*
* @param array $values 値
* @param array $options オプション
* @return BEAR_Ro
* @author Ryo HAYASHI<ryo88c at gmail.com>
* @version 1.0.0
* App/Resource/output/json.php
*/
function outputJson($values, array $options)
{
$body = json_encode($values);
$headers = array('X-BEAR-Output: JSON' => 'Content-Type: text/javascript+json; charset=utf-8');
$ro = BEAR::factory('BEAR_Ro');
$ro->setBody($body);
$ro->setHeaders($headers);
return $ro;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment