I need to create an object in this format:
var query = {"filters":{"type":"OR","filters":[
{"type":"EQ","fieldName":"name", "value":"Point_1"},
{"type":"EQ","fieldName":"name", "value":"Point_2"},
{"type":"EQ","fieldName":"name", "value":"Point_3"}
]}};
Currently, the names of the points (Point_1, Point_2, Point_3) are stored in an array named points[]. I want to dynamically generate this object based on the array.
This is what I have tried:
var filt = {filters:[]};
for(var i in points){
filt.filters.push({"type":"EQ","fieldName":"name","value":points[i]});
}
var query = {"filters":{"type":"OR","filters":filt}};
However, this approach is not working as expected.
Could someone please point out where I might be making a mistake?