介绍:将json对象["jobcode":"111","goodunits":"000","rejectUnits":"222"],拼成
["period":"111","licensed":"000","sorned":"222"],
var productductionData = [{
"jobCode": "BYD180_190326114457",
"machCode": "博創500T",
"mouldCode": "180222",
"goodUnits": 564,
"availability": 99.97,
"quality": 96.41,
"performance": 84,
"jobManager": "MES",
"endTime": "2019-03-30 10:06:18",
"startTime": "2019-03-26 11:46:49",
"achievdRate": 5.64,
"scheduledProducedUnits": 9999,
"rejectUnits": 20,
"adjustUnits": null
}]
var groups_code = "";
for (var k = 0; k < productductionData.length; k++) {
groups_code = groups_code + '{"period":"' + productductionData[k].jobCode + '","licensed":"' + productductionData[k].goodUnits + '","sorned":"' + productductionData[k].rejectUnits + '"}' + ','
} //去除最后一个逗号
groups_code = groups_code.substring(0, groups_code.length - 1); //将字符串转成JSON对象
groups_code = '[' + groups_code + ']';
var obj_groups = JSON.parse(groups_code); //将json字符串转成json对象格式
新组成的JSON对象 = [{
"period": "BYD180_190326114457",
"licensed": "564",
"sorned": "20"
},
{
"period": "转轴M50159_190329101136",
"licensed": "1780",
"sorned": "8"
},
{
"period": "BYD150157_190329161831",
"licensed": "475",
"sorned": "0"
},
{
"period": "转轴M50159_190330095755",
"licensed": "1484",
"sorned": "84"
},
{
"period": "BYD150157_190330095936",
"licensed": "1427",
"sorned": "0"
},
{
"period": "BYD180_190330100149",
"licensed": "833",
"sorned": "76"
},
{
"period": "回转套150165_190330110209",
"licensed": "0",
"sorned": "2"
},
{
"period": "66_190401093344",
"licensed": "6906",
"sorned": "0"
},
{
"period": "转帘_190401094819",
"licensed": "0",
"sorned": "0"
},
{
"period": "BYD150157_190401102829",
"licensed": "8",
"sorned": "0"
},
{
"period": "BYD180_190401102927",
"licensed": "11929",
"sorned": "2939"
},
{
"period": "转轴M50159_190401103710",
"licensed": "21840",
"sorned": "226"
},
{
"period": "转帘_190401112654",
"licensed": "5374",
"sorned": "158"
},
{
"period": "BYD150157_190401140039",
"licensed": "4641",
"sorned": "0"
},
{
"period": "回转套150165_19041720120",
"licensed": "0",
"sorned": "0"
}]