修改json字符串中的key值
//原json 格式 {"id":"333","name":"xxxx"} //将 json 字符串转换为 json 对象 var json = JSON.parse(jsonString); var value = ""; for (var i = 0;i<json.length;i++) { value += "{\"id\":\""+json[i].id+"\",\"text\":\""+json[i].text+"\"}," } value = value.substr(0,value.length - 1); 转换后格式{"id":"333","text":"xxxx"}