0

How can I map or parse the series from the following JSON so that they can appear as integers?

    {
    "success": true
    "data": {
        "title": "Resumen de llantas TSV-400",
        "categories": [
            "400JZ-CCA",
            "400JZ-NVA",
            "400JZ-XTA",
            "400JZ-REN",
            "400JZ-SCR",
            "400JZ-GAL"
        ],
        "series": [
            "90",
            "28",
            "17",
            "223",
            "1170",
            "98"
        ]
    }
}
4

2 回答 2

1
jsondata.data.series =
  jsondata.data.series.map(function(str) { return parseInt(str, 10); });

(JS 1.6+)

于 2013-07-05T00:18:57.003 回答
1

如果您使用的是 jquery:

json.data.series = $.map(json.data.series, function(value, index) {
    return parseInt(value);
});
于 2013-07-05T00:49:33.613 回答