i have json
like
{
"type": "textbox",
"originX": "center",
"originY": "top",
"left": 1289.6,
"top": 695.43,
"width": 244.84,
"height": 36.72,
"fill": "rgb(0, 0, 0)",
"stroke": null,
"strokeWidth": 1,
"strokeDashArray": null,
"strokeLineCap": "butt",
"strokeLineJoin": "miter",
"strokeMiterLimit": 10,
"scaleX": 1,
"scaleY": 1,
"angle": 0,
"flipX": false,
"flipY": false,
"opacity": 1,
"shadow": null,
"visible": true,
"clipTo": null,
"backgroundColor": "",
"fillRule": "nonzero",
"globalCompositeOperation": "source-over",
"transformMatrix": null,
"lockMovementX": false,
"lockMovementY": false,
"evented": true,
"text": "FROM ONLY £199",
"fontSize": 25,
"fontWeight": "",
"fontFamily": "'trebuchet ms'",
"fontStyle": "",
"lineHeight": 1.3,
"textDecoration": "",
"textAlign": "left",
"textBackgroundColor": "",
"styles": {
"0": {
"1": {
"fontFamily": "'trebuchet ms'",
"fontSize": 25,
"fontWeight": "",
"fontStyle": ""
},
"2": {
"fontFamily": "'trebuchet ms'",
"fontSize": 25,
"fontWeight": "",
"fontStyle": ""
}
}
},
"minWidth": 20
}
You can see there is styles
attribute at second last, it has many other objects. when you open ony one from that you will see fontFamily
, fontSize
fontWeight
. I want to remove fontWeight
from it. For this i tried this code
if (typeof indexs['styles'] != "undefined") {
for (rowIndex in indexs['styles']) {
for (letterIndex in indexs['styles'][rowIndex]) {
if (indexs['styles'][rowIndex][letterIndex].fontWeight && indexs['styles'][rowIndex][letterIndex].fontWeight=='') {
delete indexs['styles'][rowIndex][letterIndex]['fontWeight'];
}
}
}
}
But not deleting that attribute. Am i doing anything wrong there?