I have a JSON Array and want to realize a filter engine and i try do find a solution to get all these entries with a special key:value pair and push it into a sep array.
The JSON looks like this:
var sample = {
"response": {
"things": [{
"index": 0,
"type": 1,
"img":2
},{
"index": 1,
"type": 0,
"img":1
},{
"index": 2,
"type": 1,
"img":1
}]
}
};
Example HTML:
<select name="type">
<option value="0">one</option>
<option value="1">two</option>
...
</select>
currently i have made a well running solution to filter only with one key and value, that is not the point. The problem is to take the object: Object:{param:1,param:2,param:3,param:n} and find all entries with exactly these filter pairs.
i doesnt found a correct way to handle it with multiple or how to use here, so i hope someone can help please.
var uri =['http://example.com?type=1&img=0'];
for (var i = 0, len = uri.length; i < len; i++) {
var result = this.qwertzSplit(uri[i]);
}
testing(result);
//qwertzSplit contains the Object: Object{type="1",img="0"}
function testing(result){
var obj = this.sample,indexes = [];
for (result in obj) {
if (obj.hasOwnProperty(result)) {
indexes.push(result);
}
}
console.log(indexes);
}
So in my case the solution from kolink and my current doenst work as well as i need it. And i also cant find correct way with JS to solve it. My question here isnt duplicate because the posted links handle the single way, not a multiple way.
So i must find a way to get all entries with the given key/value pairs which take out the URI