以下のJSONがあり、「ルール」オブジェクトを反復処理する必要があります。最後のルール以上のものにアクセスできるようにするために、それを正しく呼び出すことは決してできないようです。
誰かが私を正しい方向に向けることができれば、私はそれをいただければ幸いです
var rules = [{
"rule":[{
"fields":["CASE.PROSECUTED_FLAG","CASE.RESTITUTION_SIGNED"],
"conditions":["N","Y"],
"actions":"required",
"action_fields":["test1","test2"]
}],
"rule":[{
"fields":["CASE.PROSECUTED_FLAG","CASE.RESTITUTION_SIGNED"],
"conditions":["N","N"],
"actions": "required",
"action_fields": ["test3", "test4"]
}],
"rule":[{
"fields":["CASE.PROSECUTED_FLAG"],
"conditions":["Y"],
"actions": "required",
"action_fields": ["test5"]
}]
}];
function rulesControl() {
alert(rules.length);
for (var rule in rules) {
var xfields = rules[rule].rule.fields;
var conditions = rules[rule].rule.conditions;
var actions = rules[rule].rule.actions;
var action_fields = rules[rule].rule.action_fields;
//test the fields (if success, mark them, else clear them)
if (validateRule(xfields, conditions)) {
rulesAction(actions, action_fields);
} else {
ruleActionMakeClear(action_fields);
}
}
}