有没有一种快速的方法,而不使用一系列复杂的 for 循环(使用诸如下划线之类的东西?或者改进我的 MySQL 查询?)来获取我的数据,这些数据以这样的平面列表格式化:
[
{
"J_NUM": "BOAK-1212",
"X_DUE_DATE": "2012-06-20T00:00:00.000Z",
"X_LEAD_TIME": 0,
"X_NAME": "Mail List Due",
},
{
"J_NUM": "BOAK-1212",
"X_DUE_DATE": "2012-06-08T00:00:00.000Z",
"X_LEAD_TIME": 0,
"X_NAME": "Vendor Specs 2",
},
{
"J_NUM": "JEFF-2000",
"X_DUE_DATE": "2012-06-11T00:00:00.000Z",
"X_LEAD_TIME": 0,
"X_NAME": "Client Final Approval",
},
{
"J_NUM": "JEFF-2000",
"X_DUE_DATE": "2012-06-08T00:00:00.000Z",
"X_LEAD_TIME": 0,
"X_NAME": "Vendor Specs 2",
}
]
并根据某些参数对其进行嵌套/分组,在本例J_NUM
中,结果如下:
[
{
"J_NUM": "BOAK-1212",
"SCHEDULE_SERIES": [
{
"X_DUE_DATE": "2012-06-20T00:00:00.000Z",
"X_LEAD_TIME": 0,
"X_NAME": "Mail List Due",
},
{
"X_DUE_DATE": "2012-06-08T00:00:00.000Z",
"X_LEAD_TIME": 0,
"X_NAME": "Vendor Specs 2",
}
]
},
{
"J_NUM": "JEFF-2000",
"SCHEDULE_SERIES": [
{
"X_DUE_DATE": "2012-06-11T00:00:00.000Z",
"X_LEAD_TIME": 0,
"X_NAME": "Client Final Approval",
},
{
"X_DUE_DATE": "2012-06-08T00:00:00.000Z",
"X_LEAD_TIME": 0,
"X_NAME": "Vendor Specs 2",
}
]
}
]