用于遍历JSON值的Javascript

问题描述

| 我有一个json对象
r
[ 
  {
    \"id\"     : \"3443\",\"name\"   : \"Joe\",\"date1\"  : \"254\",\"date4\"  : \"261\"
  },{ \"id\"     : \"50942\",\"name\"   : \"John\",\"date2\"  : \"192\",\"date4\"  : \"195\"
  },{ \"id\"     : \"2524\",\"name\"   : \"Mary\",\"date1\"  : \"153\",\"date4\"  : \"163\"
  }
]
我希望有一个Java脚本For循环可以遍历dateX值。 我知道X在1到最大值之间。 但是以下代码不起作用:
for (j=1; j<=Max; j=j+1) {
  datestring = \'date\' + j;
  if (isset(r[i].datestring)) value[j] = r[i].datestring;
  else value[j] = null; 
}
忘了解释一下,我将isset函数定义为:
function isset(variable) {
  return typeof(variable) != \"undefined\" && variable !== null;
} 
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)