Àí½âjsonÁ½Öֽṹ£ºÊý×éºÍ¶ÔÏó
JsonÊÇÒ»ÖÖÒì³£¼òµ¥Ò׶®µÄÊý¾Ý¸ñʽ£¬¹ØÓÚjsonµÄ¹æ¶¨£¬½ö½öÈç϶øÒÑ£º
- 1£© ²¢ÁеÄÊý¾ÝÖ®¼äÓöººÅ£¨", "£©·Ö¸ô¡£
- 2£© Ó³ÉäÓÃðºÅ£¨": "£©±íʾ¡£
- 3£© ²¢ÁÐÊý¾ÝµÄ¼¯ºÏ£¨Êý×飩Ó÷½À¨ºÅ("[]")±íʾ¡£
- 4£© Ó³ÉäµÄ¼¯ºÏ£¨¶ÔÏó£©ÓôóÀ¨ºÅ£¨"{}"£©±íʾ¡£
JSONÓÐÁ½ÖֽṹÊý×éºÍ¶ÔÏó£ºÊý×é±íʾÓÐÐòÊý¾ÝµÄ¼¯ºÏ£¬¶ø¶ÔÏó±íʾÎÞÐòÊý¾ÝµÄ¼¯ºÏ¡£
¿´ÏÂÃæÀý×Ó£º
$arr = array(111,'it300.com','www.it300.com');
$arr1 = array(
'a' => 'it300.com',
'b' => 222
);
$arr2 = array(
'a' => 'it300.com',
'other' => array(
'www.it300.com',
1111
)
);
echo json_encode($arr); //[111,"it300.com","www.it300.com"]
echo json_encode($arr1); //{"a":"it300.com","b":222}
echo json_encode($arr2); //{"a":"it300.com","other":["www.it300.com",1111]}
´ÓÉÏ¿´³ö£ºÓÉÓÚjavascript²»Ö§³Ö¹ØÁªÊý×飬ËùÒÔjson_encode()Ö»½«Ë÷ÒýÊý×飨indexed array£©×ªÎªÊý×é¸ñʽ£¬¶ø½«¹ØÁªÊý×飨associative array£©×ªÎª¶ÔÏó¸ñʽ¡£
¹ØÓÚPHP¶ÔjsonÖ§³Ö˵Ã÷£º
- json_encodeÖ»Ö§³ÖUTF-8±àÂëµÄÊý¾Ý£»
- json_decodeÓÀÔ¶Ö»·´Ó³Ò»¸öPHP¶ÔÏ󣬴øÉϵڶþ¸ö²ÎÊýtrue¿É·µ»ØÊý×飺
$json = '{"a":"it300.com","other":["www.it300.com", 1111]}'; print_r(json_decode($json)); print_r(json_decode($json, true));
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ