JSON以其獨特的簡潔方便及與Javscript的無縫集成在WEB2.0時瓦風靡全球。
不過做為開發者,當看到一段很長的未格式化的JSON代碼時,你會不會感到頭暈?
{"meta": {"limit": 20, "next": "/api/v1/entry/?offset=20&limit=20&format=json", "offset": 0, "previous": null, "total_count": 43}, "objects": [{"access_ip_v4": "", "access_ip_v6": "", "architecture": "", "auto_disk_config": null, "availability_zone": "", "cell_name": "", "config_drive": "", "created_at": "2012-12-21T09:34:38+00:00", "default_ephemeral_device": "", "default_swap_device": "", "deleted": 1, "deleted_at": null, "disable_terminate": 0, "display_description": "test", "display_name": "test", "ephemeral_gb": 0, "host": "EssexController", "hostname": "test", "id": 1, "image_ref": "03419abb-c27f-4dde-bc74-b8387d1ccb30", "instance_type_id": 2, "internal_id": null, "kernel_id": "", "key_data": "", "key_name": "", "launch_index": 0, "launched_at": null, "launched_on": "EssexController", "locked": 0, "memory_mb": 512, "os_type": "", "power_state": 0, "progress": 0, "project_id": "7b9dcb8cd9434d95aebd256e0a1ace9a", "ramdisk_id": "", "reservation_id": "r-nroqjwfw", "resource_uri": "/api/v1/entry/1/", "root_device_name": "/dev/vda", "root_gb": 0, "scheduled_at": "2012-12-21T09:34:38+00:00", "server_name": "", "shutdown_terminate": 1, "task_state": "deleting", "terminated_at": null, "updated_at": "2012-12-21T09:36:07+00:00", "user_data": "", "user_id": "89b0ec701354421fa2284667d4175af7", "uuid": "03cba46d-0dfc-484c-a0cf-f5a711ba87ae", "vcpus": 1, "vm_mode": "", "vm_state": "error"}, {"access_ip_v4": "", "access_ip_v6": "", "architecture": "", "auto_disk_config": null, "availability_zone": "", "cell_name": "", "config_drive": "", "created_at": "2012-12-21T09:36:54+00:00", "default_ephemeral_device": "", "default_swap_device": "", "deleted": 1, "deleted_at": "2012-12-21T09:39:54+00:00", "disable_terminate": 0, "display_description": "abadfasfasf", "display_name": "abadfasfasf", "ephemeral_gb": 0, "host": "", "hostname": "abadfasfasf", "id": 2, "image_ref": "03419abb-c27f-4dde-bc74-b8387d1ccb30", "instance_type_id": 2, "internal_id": null, "kernel_id": "", "key_data": "", "key_name": "", "launch_index": 0, "launched_at": null, "launched_on": "", "locked": 0, "memory_mb": 512, "os_type": "", "power_state": 0, "progress": 0, "project_id": "7b9dcb8cd9434d95aebd256e0a1ace9a", "ramdisk_id": "", "reservation_id": "r-3walbsjh", "resource_uri": "/api/v1/entry/2/", "root_device_name": "", "root_gb": 0, "scheduled_at": null, "server_name": "", "shutdown_terminate": 1, "task_state": "scheduling", "terminated_at": null, "updated_at": "2012-12-21T09:36:55+00:00", "user_data": "", "user_id": "89b0ec701354421fa2284667d4175af7", "uuid": "8188198c-667f-42ae-86bd-59df6fd8fcd4", "vcpus": 1, "vm_mode": "", "vm_state": "error"}, {"access_ip_v4": "", "access_ip_v6": "", "architecture": "", "auto_disk_config": null, "availability_zone": "", "cell_name": "", "config_drive": "", "created_at": "2012-12-21T09:59:54+00:00", "default_ephemeral_device": "", "default_swap_device": "", "deleted": 1, "deleted_at": null, "disable_terminate": 0, "display_des...
不過現在不用頭疼了。
安裝如下擴展即可自動格式化JSON代碼顯示。讓你拜托煩惱:
JSONView¶
- Firefox - https://addons.mozilla.org/en-US/firefox/addon/jsonview/
- Chrome - https://chrome.google.com/webstore/detail/chklaanhfefbnpoihckbnefhakgolnmc

另外,在Eclispe下面也有一個JSON編輯器支持json代碼的格式化:
下載地址:
解壓后將兩個目錄覆蓋到eclipse根目錄即可。
自動關聯.json文件,不過需要右鍵菜單中選擇Format,不能使用快捷鍵 Ctrl+shift+F
還有一個可以在線格式化JSON的的網頁:
http://www.bejson.com/index.php
這個網頁還有一些JSON的知識介紹,簡潔明了,值得一讀。
最后一個百度APP,支持樹狀預覽,不錯: