鏈変竴绉嶅彨鍋欽SON (JavaScript Object Notation) 鐨勮交閲忕骇鏁版嵁浜ゆ崲鏍煎紡鑳藉鏇夸唬XML鐨勫伐浣溿€傚畠灏辨槸JSON銆�
鏁版嵁鏍煎紡姣旇緝绠€鍗曪紝 鏄撲簬璇诲啓锛� 鏍煎紡閮芥槸鍘嬬缉鐨勶紝 鍗犵敤甯﹀灏忥紝鏄撲簬瑙f瀽杩欑璇█銆�
瀹㈡埛绔疛avaScript鍙互绠€鍗曠殑閫氳繃eval()杩涜JSON鏁版嵁鐨勮鍙栵紝鍖呮嫭ActionScript锛� C锛� C#锛� ColdFusion锛孞ava锛孞avaScript锛孭erl锛孭HP锛孭ython锛孯uby绛夎瑷€鏈嶅姟鍣ㄧ璇█锛� 渚夸簬鏈嶅姟鍣ㄧ鐨勮В鏋愩€�
鍚勮瑷€瀵笿SON鏀寔鐨勭壒鍒ソ锛岃嚜浠嶢jax鐨勬祦琛岋紝JSON鏍煎紡浼犺緭灏辨洿娴佽浜嗐€侸SON甯歌鐢ㄤ綔搴忓垪鍖栵紝鎺ㄨ崘闃呰锛�鍏充簬Java搴忓垪鍖栦綘搴旇鐭ラ亾鐨勪竴鍒�銆�
JSON鏄粈涔堬紝閭d箞鎴戝氨鍙戝ぇ鎷涗簡锛�
鍏跺疄鎴戝湪涓哄叕鍙搁潰璇曠殑鏃跺€欙紝鎴戠粡甯告湁鎻愬埌锛屽亣濡傛垜涓嶇煡閬揓SON鏄釜浠€涔堢帺鎰忥紵浣犳€庝箞鍛婅瘔鎴戯紝璁╂垜鐭ラ亾鏄釜浠€涔堜笢瑗裤€傦紙涓嬮潰閮芥槸鎴戠殑涓汉鐞嗚В锛屽洜鐞嗚В鍥犱汉鑰屽紓锛屽彈鐢ㄥ嵆鍙紒锛�
闂簡杩欎箞澶氫汉锛屽叾瀹炵粨鏋滀笉鏄垜鎯宠鐨勶紝澶у鏁扮殑绛旀鏈夎繖浜涖€�
瀹冩槸鍓嶇鍜屽悗鍙颁氦浜掔敤鐨勩€�
瀹冩槸閿€煎鐨勩€�
浠ヤ笂2鐐规瘮杈冨銆傝繕鏈変竴浜涗贡涓冨叓绯熺殑瀹屽叏鍋忕浜咼SON銆傞偅涔堝畠搴旇鏄€庢牱鐨勶紵搴旇杩欎箞鍥炵瓟锛屼釜浜鸿涓猴紒
棣栧厛锛屽畠鍙槸涓€涓瓧绗︿覆锛屽畠鍙槸涓€涓湁瑙勫垯鐨勫瓧绗︿覆銆傦紙閲嶇偣锛夌劧鍚庡畠鐨勮〃杈撅紙琛ㄧ幇锛夊舰寮忔槸閿€煎鐨勩€傚叾瀹為潪甯哥被浼糐ava璇█閲岀殑Map锛孫bjective-C閲岀殑瀛楀吀锛屽叾浠栬瑷€閮芥湁瀵瑰簲鐨勶紝鎴戣瀹炶瘽鍏朵粬璇█鎴戜笉鐭ラ亾锛�
鎴戜负浠€涔堢敤MapString娉涘瀷锛屽洜涓虹悊璁轰笂瀹冪殑閿€煎搴旇閮芥槸瀛楃涓诧紝Why锛熻繖涓棶棰橀棶鐨勫ソ锛屾垜鍙互杩欎箞鍥炵瓟浣狅紝鍥犱负瀹冩湰韬氨鏄瓧绗︿覆銆�
涓婇潰璇寸殑鐞嗚涓婅〃杈炬柟寮忥紝閭d箞瀹為檯鐩墠鎴戜滑鐢ㄥ埌鐨勯敭鍊煎鏀寔浠€涔堝憿锛熷彲浠ユ敮鎸丼tring銆丯umber銆丄rray浠ュ強Boolean銆乶ull浠€涔堢殑銆�
瀹冪殑浣滅敤鏄敤鏉ヤ氦浜掔殑锛屼笉涓€瀹歐eb椤圭洰鐨勫墠鍚庣浜や簰涔熷彲浠ユ帴鍙o紝閰嶇疆鏂囦欢锛屾枃浠跺瓨鍌ㄧ瓑绛夐兘OK銆傜洰鍓嶇Щ鍔ㄧ姣旇緝鐏紝涓€鑸殑椤圭洰閮戒細鐢↗SON鏉ヤ紶杈撱€�
涓婃墜瀹规槗锛岄珮鏁堛€�
璺ㄨ瑷€锛岀洰鍓嶇Щ鍔ㄧAndroid銆両OS涓€鑸」鐩瀯閫犻兘鏄叾浠栬瑷€鎻愪緵鎺ュ彛锛圝SON鏂瑰紡锛夛紝绉诲姩绔鍙栨帴鍙g殑鏂瑰紡寮€鍙戙€�
鈥�.
鍙鎬�
鐪嬩簡缃戜笂鐨勫悇绉嶅笘瀛愶紝鏈夎鍙鎬х浉褰擄紝涓嶈繃鍩烘湰鏄XML鍙鎬уソ锛屾垜璁や负杩樺噾鍚堛€傚彲浠ユ墦骞虫墜銆�
鍙墿灞曟€�
鏈変汉璇达紝鈥淴ML澶╃敓鏈夊緢濂界殑鎵╁睍鎬э紝JSON褰撶劧涔熸湁锛屾病鏈変粈涔堟槸XML鑳芥墿灞曪紝JSON涓嶈兘鐨勩€�
涓嶈繃 JSON鍦↗avascript涓诲満浣滄垬锛屽彲浠ュ瓨鍌↗avascript澶嶅悎瀵硅薄锛屾湁鐫€XML涓嶅彲姣旀嫙鐨勪紭鍔库€濄€傛垜璧炲悓涓€鍗婏紝鎴戣寰楄繖浜涘笘瀛愰兘鏄€佸笘瀛愶紝XML鍙互鐏垫椿鎵╁睍鏄洜涓哄悇绉嶈瑷€鏈夋敮鎸佺殑鍏朵粬Jar鍖咃紝绫诲簱绛夈€�
浣嗚嚜浠嶫SON鐏捣鏉ュ悗锛孞SON鐨勬敮鎸佸寘锛岀被搴撶瓑锛岀浉淇℃瘡涓瑷€閮藉緢澶氥€傚儚Java灏辨湁Jackson銆乬oson銆乯son-lib銆丗astJson绛夌瓑澶氱殑鍘讳簡銆�
缂栫爜闅惧害
XML鏈夋湁DOM锛孲AX锛孲TAX绛夎В鏋愭妧鏈紝JSON涔熸湁鎴戜笂闈㈣鐨勯偅浜涳紝閮絆K銆�
瑙g爜闅惧害
鍚屼笂銆�
瑙g爜缂栫爜鏁堢巼
鍛靛懙锛佽В鏋怷ML鏈変笓鐢–PU銆佷綘閫犲悧锛�
<country>
<name>涓浗</name>
<province>
<name>榛戦緳姹�</name>
<citys>
<city>鍝堝皵婊�</city>
<city>澶у簡</city>
</citys>
</province>
<province>
<name>骞夸笢</name>
<citys>
<city>骞垮窞</city>
<city>娣卞湷</city>
<city>鐝犳捣</city>
</citys>
</province>
<province>
<name>鍙版咕</name>
<citys>
<city>鍙板寳</city>
<city>楂橀泟</city>
</citys>
</province>
<province>
<name>鏂扮枂</name>
<citys>
<city>涔岄瞾鏈ㄩ綈</city>
</citys>
</province>
</country>
{
"name": "涓浗"锛�
"province": [
{
"name": "榛戦緳姹�"锛�
"citys": {
"city": [
"鍝堝皵婊�"锛�
"澶у簡"
]
}
}锛�
{
"name": "骞夸笢"锛�
"citys": {
"city": [
"骞垮窞"锛�
"娣卞湷"锛�
"鐝犳捣"
]
}
}锛�
{
"name": "鍙版咕"锛�
"citys": {
"city": [
"鍙板寳"锛�
"楂橀泟"
]
}
}锛�
{
"name": "鏂扮枂"锛�
"citys": {
"city": [
"涔岄瞾鏈ㄩ綈"
]
}
}
]
}
鎴戜滑鍦ㄦ棩甯稿紑鍙戜腑灏戜笉浜嗗拰JSON鏁版嵁鎵撲氦閬擄紝閭d箞鎴戜滑鏉ョ湅鐪婮AVA涓父鐢ㄧ殑JSON瑙f瀽鏂瑰紡銆侸SON甯歌鐢ㄤ綔搴忓垪鍖栵紝鎺ㄨ崘闃呰锛�鍏充簬Java搴忓垪鍖栦綘搴旇鐭ラ亾鐨勪竴鍒�銆�
JSON瀹樻柟
GSON
FastJSON
Jackson
鈶犳湰绔欓儴鍒嗗伐鍏烽兘鏉ユ簮浜庣綉缁滃拰缃戝弸鎻愪緵锛屽鏈夌増鏉冮棶棰橈紝璇疯仈绯绘湰绔欙紒
鈶℃湰绔欏伐鍏蜂粎涓轰簡澶у鏂逛究浣跨敤锛岃鍕跨敤浜庤繚娉曘€佸晢鍔°€佷氦鏄� 绛夋柟闈紒鍚﹀垯鏈珯姒備笉璐熻矗锛�