{"id":26273947,"url":"https://github.com/hash-bang/simplejsonfilter","last_synced_at":"2025-08-02T13:10:20.638Z","repository":{"id":10505553,"uuid":"12691124","full_name":"hash-bang/simpleJSONFilter","owner":"hash-bang","description":"Extremely simple JSON filtering system","archived":false,"fork":false,"pushed_at":"2013-09-17T02:38:11.000Z","size":107,"stargazers_count":9,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-21T11:25:51.997Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hash-bang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-09T02:02:37.000Z","updated_at":"2017-07-03T23:06:21.000Z","dependencies_parsed_at":"2022-09-26T17:41:28.474Z","dependency_job_id":null,"html_url":"https://github.com/hash-bang/simpleJSONFilter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hash-bang/simpleJSONFilter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2FsimpleJSONFilter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2FsimpleJSONFilter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2FsimpleJSONFilter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2FsimpleJSONFilter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hash-bang","download_url":"https://codeload.github.com/hash-bang/simpleJSONFilter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2FsimpleJSONFilter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268394003,"owners_count":24243336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-14T09:17:30.498Z","updated_at":"2025-08-02T13:10:20.615Z","avatar_url":"https://github.com/hash-bang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"SimpleJSONFilter\n================\nExtremely simple, yet configurable, JSON filtering system.\n\nThis module provides an object aimed at filtering arrays (or hashes) of hashes.\n\nThe need for it is based on wanting an [ActiveRecord](http://ellislab.com/codeigniter/user-guide/database/active_record.html) like 'where' condition using only JSON arrays-of-hashes or hashes-of-hashes.\n\nIt can be thought of as an extremely dumbed down and easy to understand RegExp group capture operation.\n\n\nExamples\n========\nAssume the following data structure in all examples:\n\n\tvar data = {\n\t\tone: {\n\t\t\tid: 1,\n\t\t\tname: 'Hiro Protagonist',\n\t\t\tage: 27\n\t\t},\n\t\ttwo: {\n\t\t\tid: 2,\n\t\t\tname: 'Y.T.',\n\t\t\tage: 16\n\t\t},\n\t\tthree: {\n\t\t\tid: 3,\n\t\t\tname: 'Raven',\n\t\t\tage: 40,\n\t\t},\n\t\tfour: {\n\t\t\tid: 4,\n\t\t\tname: 'Uncle Enzo',\n\t\t\tage: 80\n\t\t},\n\t\tfive: {\n\t\t\tid: 5,\n\t\t\tname: 'Fisheye',\n\t\t\tage: 50\n\t\t}\n\t};\n\n\nExample of very simple `key=val` filtering\n\n\tvar simpleJSONFilter = require(\"./index.js\");\n\tvar sjf = new simpleJSONFilter();\n\tvar filter = {id: 1};\n\tvar result = sjf.exec(filter, data); // Returns {one: {id: 1,name: 'Hiro Protagonist',age: 27}}\n\nExample of complex filtering with conditionals\n\n\tvar simpleJSONFilter = require(\"./index.js\");\n\tvar sjf = new simpleJSONFilter();\n\tvar filter = {'age \u003e 40'};\n\tvar result = sjf.exec(filter, data); // Returns the keys \u0026 values of 'three', 'four' and 'five'\n\nDefinining your own handlers\n\n\tvar simpleJSONFilter = require(\"./index.js\");\n\tvar sjf = new simpleJSONFilter();\n\tsjf.addHandler(/^(.*) ends with$/, function(key, val, data) {\n\t\tvar str = data[key] + '';\n\t\treturn (str.substr(str.length - val.length) == val);\n\t});\n\n\tvar filter = {'age ends with': '0'};\n\tsjf.exec(filter, data), // Returns the keys \u0026 values of 'three', 'four' and 'five'\n\nAlternate syntax\n\n\tvar simpleJSONFilter = require(\"./index.js\");\n\tvar sjf = new simpleJSONFilter();\n\tsjf\n\t\t.filter({'age \u003c=': '40'})\n\t\t.data(data)\n\t\t.exec(); // Returns keys \u0026 values of 'one', 'two' and 'three'\n\nLimit the number of returned items\n\n\tvar simpleJSONFilter = require(\"./index.js\");\n\tvar sjf = new simpleJSONFilter();\n\tsjf\n\t\t.filter({'age \u003c=': '40'})\n\t\t.data(data)\n\t\t.limit(1)\n\t\t.exec(); // Returns keys \u0026 values of 'one' (as it has a limit of one)\n\nLimit the number of returned items \u0026 return an array\n\n\tvar simpleJSONFilter = require(\"./index.js\");\n\tvar sjf = new simpleJSONFilter();\n\tsjf\n\t\t.filter({'age \u003c=': '40'})\n\t\t.data(data)\n\t\t.limit(1)\n\t\t.wantArray()\n\t\t.exec(); // Returns a single item array of 'one'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhash-bang%2Fsimplejsonfilter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhash-bang%2Fsimplejsonfilter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhash-bang%2Fsimplejsonfilter/lists"}