在Chrome中,JSON數據可以通過Chrome DevTools面板中的Sources選項卡查看和編輯。當處理大量JSON數據時,對其進行排序可以使數據更易于瀏覽和分析。
示例JSON數據: { "name": "John", "age": 30, "gender": "male", "address": { "street": "123 Main St", "city": "New York", "state": "NY", "zip": "10001" }, "phoneNumbers": [ { "type": "home", "number": "555-555-1234" }, { "type": "work", "number": "555-555-5678" } ] } 對JSON數據按字母順序排序: { "address": { "city": "New York", "state": "NY", "street": "123 Main St", "zip": "10001" }, "age": 30, "gender": "male", "name": "John", "phoneNumbers": [ { "number": "555-555-1234", "type": "home" }, { "number": "555-555-5678", "type": "work" } ] }
使用Chrome DevTools面板中的Sources選項卡,可以使用快捷鍵Ctrl + Shift + P調出命令菜單,輸入“Format JSON”,點擊運行,從而按照字母順序自動排序JSON數據。