删除javascript中json键的数字

删除javascript中json键的数字,javascript,regex,json,Javascript,Regex,Json,我发现JSON中的以下输出为: [{ "ApplicationView": "", "Styling": "", "minwidth": "450px", "minheight": "350px", "kendoWindowWidth": "90%", "kendoWindowHeight": "90%", "iconSize": "20px", "viewerToolColor": "#8dcaf7", "DefaultV

我发现JSON中的以下输出为:

[{
    "ApplicationView": "",
    "Styling": "",
    "minwidth": "450px",
    "minheight": "350px",
    "kendoWindowWidth": "90%",
    "kendoWindowHeight": "90%",
    "iconSize": "20px",
    "viewerToolColor": "#8dcaf7",
    "DefaultView": "fit To Screen",
    "Email": "",
    "To": "ToPerson",
    "Subject": "This file is exported from actual program.",
    "From": "FromPerson",
    "Body": "This file is exported from actual program.",
    "Content": "",
    "zoomIn": "",
    "Icon16": "ZoomIn.png",
    "Label17": "Zoom In",
    "Visibility18": "true",
    "zoomOut": "",
    "Icon20": "ZoomOut.png",
    "Label21": "Zoom Out",
    "Visibility22": "true",
    "rotateLeft": null,
    "Icon24": "RotateLeft.png",
    "Label25": "Rotate Left",
    "Visibility26": "true",
    "rotateRight": "",
    "Icon28": "RotateRight.png",
    "Label29": "Rotate Right",
    "Visibility30": "true",
    "fitToScreen": "",
    "Icon32": "fittoscreen.png",
    "Label33": "Fit to Screen or Double Click on Image",
    "Visibility34": "true",
    "fullScreen": "",
    "Icon36": "fullscreen.png",
    "Label37": "Full Screen or 2 Times Double Click on Image",
    "Visibility38": "true",
    "saveAs": "",
    "Icon40": "download.png",
    "Label41": "Full Screen or 2 Times Double Click on Image",
    "Visibility42": "true",
    "print": "",
    "Icon44": "print.png",
    "Label45": "Print",
    "Visibility46": "true",
    "email": "Email",
    "Icon48": "email.png",
    "Label49": "Send Mail",
    "Visibility50": "true"
}]
我想从JSON的键中删除数字

示例:icon48将是一个图标

请指导我这样做

我试图在foreach循环中访问json的键,并使用正则表达式删除数字,但没有成功


非常感谢您的帮助。

不要试图直接处理JSON字符串:您确实应该在更改它之前解析它

var arr1 = JSON.parse(yourJSON);
var arr2 = arr1.map(function(o1){
    var o2 = {};
    for (var key in o1) {
        o2[key.replace(/\d+/g,'')] = o1[key];
    }
    return o2;
});
var finalJSON = JSON.stringify(arr2);
如果您实际上没有任何JSON,而只有一个普通JavaScript数组,请跳过第一步和最后一步


首先,您是有一个实际的JSON字符串,还是有一个javascript对象?第二,到目前为止你试过什么?向我们展示一些代码。这个或类似的问题必须至少回答100次。请做一个搜索。我试过了,但是没有一个成功。我从过去的5个小时就开始搜索了。所以你应该只使用图标而不是图标16?除了Icon20,你还应该有Icon?他们不能有同一把钥匙吗?不,他们不能。当我使用时,钥匙被更换了。不工作,先生。myJsonString=JSON.stringifyyuiop;yuiop是我在其中推送所有值的数组的名称。。你能检查一下你有什么不同吗?亲爱的先生,检查一下你的演示。放大后没有图标、标签和可视性显示。