<!DOCTYPE html> <html> <head> <title></title> <meta charset="utf8"> </head> <body> <script type="text/javascript"> var s = { "Kaohsiung" : [ { "zip" : 800, "city" : "新興區" },{ "zip" : 801, "city" : "前金區" } ] }; //JSON to String s = JSON.stringify(s); console.debug(s); //String to JSON s = JSON.parse(s); console.debug(s); </script> </body> </html>
參考資料:
http://msdn.microsoft.com/zh-tw/library/cc836466(v=vs.94).aspx
http://msdn.microsoft.com/zh-tw/library/cc836459(v=vs.94).aspx