regex - Remove numbers from key of json in javascript -


i find following output in json as:

[{     "applicationview": "",     "styling": "",     "minwidth": "450px",     "minheight": "350px",     "kendowindowwidth": "90%",     "kendowindowheight": "90%",     "iconsize": "20px",     "viewertoolcolor": "#8dcaf7",     "defaultview": "fit screen",     "email": "",     "to": "toperson",     "subject": "this file exported actual program.",     "from": "fromperson",     "body": "this file exported 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 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" }] 

i want remove numbers keys of json

example: icon48 icon.

kindly guide me in doing this.

i trying access keys of json in foreach loop , using regular expression remove numbers did not succeed while doing it.

help appreciated.

don't try work directly on json string : really should parse before changing it.

var arr1 = json.parse(yourjson); var arr2 = arr1.map(function(o1){     var o2 = {};     (var key in o1) {         o2[key.replace(/\d+/g,'')] = o1[key];     }     return o2; }); var finaljson = json.stringify(arr2); 

skip first , last steps if don't have, in fact, json plain javascript array.

demonstration


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -