2009년 09월 11일
php-json
누군가 PHP에서 JSON 타입으로 프로그래밍을 시도한게 있긴 한가부다.
관련 레퍼런스 참고하도록 하자.
http://mike.teczno.com/JSON/doc/
-----------------------------------------------------------------------------------------
http://pear.php.net/pepr/pepr-proposal-show.php?id=198
[출처] PHP JSON Library (Web Programmer 2.0) |작성자 치토스
http://cafe.naver.com/q69/116151
is a PHP implementation of JSON, freely-available for download and use from pear.php.net. This project has a public Yahoo! group for bug reports, updates, rants, etc.
JSON-PHP
JSON (JavaScript Object Notation) is a lightweight data-interchange format. In experimenting with XMLHTTPRequest, I've found that using a less-bloaty data exchange format beats XML. It's also perfect for the growing body of Ajax code, examples of which can be found at Ajax Matters.
In Javascript, consuming input in JSON format is as easy as:
eval("var decoded_data = "+encoded_data); With JSON-PHP, it can be almost as easy on the server-side, too:
// create a new instance of Services_JSON
require_once('JSON.php');
$json = new Services_JSON();
// convert a complex value to JSON notation
$value = array(1, 2, 'foo');
$output = $json->encode($value);
print($output);
// accept incoming POST data
$input = $GLOBALS['HTTP_RAW_POST_DATA'];
$value = $json->decode($input); JSON is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. This feature can also be found in Python. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, TCL, and many others. These properties make JSON an ideal data-interchange language.
JSON-PHP is available in fully-functional proposal form from the PEAR site, under the PHP license.
If you're comfortable with compiling PHP extensions from source, and have root privileges on the machines you use, there is a C implementation of JSON for PHP available, with big speed advantages over JSON-PHP.
# by | 2009/09/11 15:25 | 잡담 | 트랙백 | 덧글(0)




☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]