aa = ["한글", "id", "contactId", "fullName"];껌임.
_params['test'] = Ext.util.JSON.encode( aa );
헌데 여기서 엄청난 사질이 있었음...
php쪽
$test = stripslashes( iconv('utf-8', 'cp949', $test ) );stripslahses안 해주면 decode안됨
print_r ( json_decode( $test ) )
aa = ["한글", "id", "contactId", "fullName"];껌임.
_params['test'] = Ext.util.JSON.encode( aa );
$test = stripslashes( iconv('utf-8', 'cp949', $test ) );stripslahses안 해주면 decode안됨
print_r ( json_decode( $test ) )
htmlspecialchars로 변경된 데이터를 encode / decode하는 경우
php version 5 이상에서는 htmlspecialchars_decode 가 기본 function이지만 없는 경우 만들어 써야 함.function htmlspecialchars_decode($string, $quote_style = null)
{
// Sanity check
if (!is_scalar($string)) {
user_error('htmlspecialchars_decode() expects parameter 1 to be string, ' .
gettype($string) . ' given', E_USER_WARNING);
return;
}
if (!is_int($quote_style) && $quote_style !== null) {
user_error('htmlspecialchars_decode() expects parameter 2 to be integer, ' .
gettype($quote_style) . ' given', E_USER_WARNING);
return;
}
// Init
$from = array('&', '<', '>');
$to = array('&', '<', '>');
// The function does not behave as documented
// This matches the actual behaviour of the function
if ($quote_style & ENT_COMPAT || $quote_style & ENT_QUOTES) {
$from[] = '"';
$to[] = '"';
$from[] = ''';
$to[] = "'";
}
return str_replace($from, $to, $string);
}
// view action이고 결과 출력이 XMLRPC일 경우 해당 모듈의 api method를 실행
if($this->module_info->module_type == 'view'){
if(Context::getResponseMethod() == 'XMLRPC' || Context::getResponseMethod() == 'JSON') {
$oAPI = getAPI($this->module_info->module, 'api');
if(method_exists($oAPI, $this->act)) {
$oAPI->{$this->act}($this);
}
}
}else if($this->module_info->module_type == 'controller'){
if(Context::getResponseMethod() == 'JSON'){
}
}
return true;
}
}
?>