s24344,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
</head>
<body>
<ul class="list"></ul>
<script>
function fn(arr, pattern) {
return arr.filter(function(el) {
return pattern.some(function(mask) {
return Object.keys(mask).every(function(key) {
return mask[key](el[key])
})
})
})
};
var json = '{"products": [{"id": "1", "code": "LDS51", "title": "Kindness", "disabled": "true"}, {"id": "2", "code": "LF532", "title": "Some sample", "disabled": "false"}, {"id": "3", "code": "LF532", "title": "Some sample", "disabled": "true"}, {"id": "4", "code": "LF532", "title": "Some sample"}]}',
obj = JSON.parse(json),
arr = obj.products,
pattern = [{disabled:function(disabled) {
return disabled === "true"
}}],
arrFilter = fn(arr, pattern),
html = arrFilter.reduce(function(html, el) {
return html += '<li class="item" data-id="'+el.id+'" ><div>'+el.title+'</div></li>'
},"");
document.querySelector(".list").innerHTML = html;
</script>
</body>
</html>