我有以下 json
{"groupOp":"AND","rules":[{"field":"company","op":"cn","data":"School"}]}
我想将新属性注入规则数组中的每个项目以获得类似的东西。
{"groupOp":"AND","rules":[{"field":"company","op":"cn","data":"School", "dataType": "Organization", "dataProperty": "name"}]}
计划是遍历称为规则的数组并使用以下内容动态添加正确的值。
var filters = $.parseJSON(postData.filters);
var rules = filters.rules;
for (i = 0; i < rules.length; i++) {
rules[i]
}
我可以访问索引“i”处的规则。我试过了rules[0].push({dataType: "Organization"});
请帮忙。