所以我有以下 JSON 对象:
var myObj = {
Name: "Paul",
Address: "27 Light Avenue"
}
我想将其键转换为小写,这样我会得到:
var newObj = {
name: "Paul",
address: "27 Light Avenue"
}
我尝试了以下方法:
var newObj = mapLower(myObj, function(field) {
return field.toLowerCase();
})
function mapLower(obj, mapFunc) {
return Object.keys(obj).reduce(function(result,key) {
result[key] = mapFunc(obj[key])
return result;
}, {})
}
但我收到一条错误消息“Uncaught TypeError: field.toLowerCase is not a function”。
 ibeautiful
ibeautiful 
					幕布斯6054654
 
					慕田峪7331174
 
					摇曳的蔷薇
 
					HUX布斯
 随时随地看视频慕课网APP
随时随地看视频慕课网APP
相关分类