[Solved] Replace string array in a JSON to integer array [closed]


const data = {"chart": {"type": "column"},"credits": {"enabled": true,"href": "#","position": {"align": "right","verticalAlign": "bottom","y": 0},"text": "www.midasplus.com"},"series": [{"color": {"linearGradient": {"x1": 1,"x2": 0,"y1": 0,"y2": 1},"stops": [[0,"#9a1919"],["0.25","#9a1919"],["0.5","#9a7319"],["0.75","#9a1919"],[1,"#9a1919"]]},"data": ["-1.03","-3.01","-2.25","0.63","-1.07","1.14","-0.38","2.03","-2.07","-3.55","-3.99","-0.41"],"negativeColor": {"linearGradient": {"x1": -1,"x2": 0,"y1": 0,"y2": -1},"stops": [[0,"#199A19"],["0.25","#199A19"],["0.5","#00CC00"],["0.75","#199A19"],[1,"#199A19"]]},"showInLegend": "false"}],"title": {"text": "Control Chart"},"xAxis": {"categories": ["Q3 2013","Q4 2013","Q1 2014","Q2 2014","Q3 2014","Q4 2014","Q1 2015","Q2 2015","Q3 2015","Q4 2015","Q1 2016","Q2 2016"]} }    
const floatArr = data.series[0].data.map(item => {
    return parseFloat(item)
})

If you want these as integers, please use function parseInt(item, 10) with parseFloat(item).

0

solved Replace string array in a JSON to integer array [closed]