JSON字符串: var str1 = '{ "name": "cxh", "sex": "man" }'; JSON對象: var str2 = { "name": "cxh", "sex": "man" };
1.字符串轉JSONspa
var obj = JSON.parse(str1);
2.JSON轉字符串code
var str=JSON.stringify(obj);
3.JSON增長元素對象
obj['key']=value;
4.JSON刪除元素blog
delete obj["key"];
5.JSON按數字排序排序
obj.sort(sortBy('key', false, parseInt));
6.JSON按字符串排序字符串
obj.sort(sortBy('key', false, String));