var days = new Array("sun", "mon", "tue", "wed", "thu", "fri", "sat");
$.each(data, function (i, object) {
$.each(object, function (property, value) {
var propertyString = getPropertyAsString(property);
if ($.inArray(propertyString, days) != -1)
{
// do something
}
count++;
});
});
以上是我使用jquery從json中檢索數據的代碼存根。我想要做的就是在「property
名」(我是用getPropertyAsString()
嵌套$.each()
內爲一個字符串,然後,我要檢查,如果這個「屬性名」天陣的存在與否標記。檢索屬性名稱作爲字符串jSon jQuery
更具體地講,下面是JSON:
[{
"STID": 0,
"VRNO": 0,
"VRNOA": 0,
"VRDATE": "\/Date(-62135596800000)\/",
"PARTY_ID": null,
"BILTY_NO": null,
"BILTY_DATE": "\/Date(-62135596800000)\/",
"RECEIVED_BY": null,
"TRANSPORTER_ID": null,
"REMARKS": null,
"Year_srno": 0,
"ETYPE": null,
"NAMOUNT": 0,
"UID": 0,
"ORDER_VRNO": 0,
"FREIGHT": 0,
"PARTY_ID_CO": null,
"SALEBILLNO": 0,
"DISCP": 0,
"DISCOUNT": 0,
"CURRENCY_ID": 0,
"EXPENSE": 0,
"COMPANY_ID": 0,
"VEHICLE_ID": null,
"PARTY_NAME": null,
"isEditted": false,
"isDeleted": false,
"isNew": false,
"Mon": "0",
"Tue": "0",
"Wed": "0",
"Thu": "500",
"Fri": "0",
"Sat": "0",
"Sun": "0"
}]
我試圖做的是在年底,即週一,週二,週三,週四,週五,週六,週日
得到了週日期值我一直在努力嘗試,找不到方法去做。請親們建議我是否有辦法。
此外,當我嘗試'Console.log(屬性)',名稱確實顯示在控制檯中,但我不能夠在上面的代碼中使用它,我也嘗試過'property.toString()'以及但不能得到exp反應結果:( –