基于特定类型的Key循环遍历JSON对象 [英] Looping through JSON object based on particular type of Key

查看:92
本文介绍了基于特定类型的Key循环遍历JSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,

我有以下Json对象

Hi Friends,
I have following Json Object

"lstTimesheet":[{"ConventionID":1,"PhaseID":139,"ActivityID":259,"TaskID":10,"Day1":8.00,"Day2":8.00,"Day3":0.00,"Day4":0.00,"Day5":0.00,"Day6":0.00,"Day7":0.00,"MSPFlag":0,"TimesheetFormat":"MH ","Freeze":0}]}





我正在尝试的是,我只想通过具有Day的键进行迭代



我试图跟随:



What I'm trying is, I want only iterate only through keys which has "Day"

I was trying following:

$.each(data.obj.lstTimesheet, function (i, obj) {
                                var txtID = 'txtTime' + (i + 1);
                                var Day = 'Day' + (i + 1);

                                $('#Grid tbody tr').eq(i).each(function () {
                                    $(this).find('td').eq(1).find(txtID).append(obj[Day]);
                                });
                            });





但它没有。



任何想法wh我错了吗?



先谢谢



But it is not doing.

Any idea where I'm going wrong??

Thanks in Advance

推荐答案

.each(data.obj) .lstTimesheet,function(i,obj){
var txtID ='txtTime'+(i + 1);
var Day ='Day'+(i + 1);
.each(data.obj.lstTimesheet, function (i, obj) { var txtID = 'txtTime' + (i + 1); var Day = 'Day' + (i + 1);


('#Grid tbody tr')。eq(i).each(function(){
('#Grid tbody tr').eq(i).each(function () {


(this).find('td')。eq(1).find(txtID)。append(obj [Day]);
});
});
(this).find('td').eq(1).find(txtID).append(obj[Day]); }); });





但它没有。



知道我哪里错了吗?



先谢谢



But it is not doing.

Any idea where I'm going wrong??

Thanks in Advance


这篇关于基于特定类型的Key循环遍历JSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆