2008년 4월 3일 목요일

Json사용을 위한 셋팅2

pear에서 json관련 라이브러리를 설치 하면
json_encode와 json_decode를 아무데서나 call할 수 있는 환경이 된다.
하..지..만 설치가 되지 않는 경우도 있다.


<?php
if ( !function_exists('json_decode'
) ){
    function
json_decode($content, $assoc=false
){
                require_once
'Services/JSON.php'
;
                if (
$assoc
){
                   
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE
);
        } else {
                   
$json = new Services_JSON
;
                }
        return
$json->decode($content
);
    }
}

if ( !
function_exists('json_encode'
) ){
    function
json_encode($content
){
                require_once
'Services/JSON.php'
;
               
$json = new Services_JSON
;
               
        return
$json->encode($content
);
    }
}
?>
참조 사이트: http://pear.php.net/pepr/pepr-proposal-show.php?id=198


댓글 없음:

댓글 쓰기