{"id":20594493,"url":"https://github.com/mainak55512/jsonprocessor","last_synced_at":"2026-04-11T09:02:31.579Z","repository":{"id":204335954,"uuid":"711603740","full_name":"mainak55512/JSONProcessor","owner":"mainak55512","description":"Simple JSON query tool for JS","archived":false,"fork":false,"pushed_at":"2024-09-30T17:46:49.000Z","size":90,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T00:32:02.279Z","etag":null,"topics":["cli","javascript","jq","json","library","linux","npm-package","open-source","query","sql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mainak55512.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-29T19:05:32.000Z","updated_at":"2024-09-30T17:49:03.000Z","dependencies_parsed_at":"2024-06-15T12:50:17.798Z","dependency_job_id":"6a49b299-2467-4aed-af78-5197fd58abba","html_url":"https://github.com/mainak55512/JSONProcessor","commit_stats":null,"previous_names":["mainak55512/jsonprocessor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mainak55512%2FJSONProcessor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mainak55512%2FJSONProcessor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mainak55512%2FJSONProcessor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mainak55512%2FJSONProcessor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mainak55512","download_url":"https://codeload.github.com/mainak55512/JSONProcessor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242229352,"owners_count":20093375,"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","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":["cli","javascript","jq","json","library","linux","npm-package","open-source","query","sql"],"created_at":"2024-11-16T08:09:13.770Z","updated_at":"2025-12-31T00:54:24.846Z","avatar_url":"https://github.com/mainak55512.png","language":"JavaScript","readme":"# Jproc\n\nJproc is a light-weight simple json array query tool written in JavaScript.\n\n\n## Installation\n\n```\nnpm install jproc\n```\nor,\n```\nnpm i jproc\n```\n\n## New jproc CLI is now available\n\n🎉New 'jproc' cli released.🎉\nTry out new 'jproc' cli tool available in [releases](https://github.com/mainak55512/JSONProcessor/releases).\n\nCheck out [Jproc-cli-usage](#Jproc-cli-usage) section for more details\n## Sample data.json\n\n```json\n[\n    {\n        \"name\": \"name_1\",\n        \"age\": 18,\n        \"details\": {\n            \"id\": \"hvnakds2342349\",\n            \"location\": \"London\",\n            \"company\": \"xyz\",\n            \"keywords\": [\n                \"test1\",\n                \"test2\",\n                \"test3\"\n            ]\n        }\n    },\n    {\n        \"name\": \"name_2\",\n        \"age\": 20,\n        \"details\": {\n            \"id\": \"iuefibe8362873287\",\n            \"location\": \"London\",\n            \"company\": \"abc\",\n            \"keywords\": [\n                \"test1\",\n                \"test2\",\n                \"test3\"\n            ]\n        }\n    },\n    {\n        \"name\": \"name_3\",\n        \"age\": 19,\n        \"details\": {\n            \"id\": \"iwhiuvwi766579\",\n            \"location\": \"New York\",\n            \"company\": \"xyz\",\n            \"keywords\": [\n                \"test1\",\n                \"test2\",\n                \"test3\"\n            ]\n        }\n    },\n    {\n        \"name\": \"name_4\",\n        \"age\": 25,\n        \"details\": {\n            \"id\": \"wuwcuwey652362\",\n            \"location\": \"Iraq\",\n            \"company\": \"pqr\",\n            \"keywords\": [\n                \"test1\",\n                \"test2\",\n                \"test3\"\n            ]\n        }\n    }\n]\n\n```\n\n## Example usage:\n\n```javascript\nimport Jproc from \"jproc\";\nimport fs from \"fs\";\n\nlet data = JSON.parse(fs.readFileSync(\"./data.json\"));\n\n\n// Initialize Jproc object with json data.\nlet jObj = new Jproc(data);\n\n\n//------------------------------------ Example 1 ----------------------------------------\n\n// Optionally you can set which parameters you want in the resultant array form the original json object.\njObj.neededParams([\"name\", \"details.id\"]);\n\n// Set query for the jproc object, if no query is set using setQuery() method, then it will return resultant array \n// with the fields specified by neededParams() method. If no parameter or query specified, then it will throw error.\njObj.setQuery(\"(age \u003e= 20 || (age \u003e 18 \u0026\u0026 details.company = 'xyz')) \u0026\u0026 (details.location = 'London' || details.location = 'New York')\");\n\n// Finally call exec_query() method to execute the query.\nconsole.log(JSON.stringify(jObj.exec_query()));\n\n/*\n It matches the condition and returns the fields specified in the neededParams() method called before.\n output:\n --------\n[\n  {\n    \"name\": \"name_2\",\n    \"id\": \"iuefibe8362873287\"\n  },\n  {\n    \"name\": \"name_3\",\n    \"id\": \"iwhiuvwi766579\"\n  }\n]\n*/\n// ----------------------------------- End of Example 1 -------------------------------------\n\n\n// -------------------------------------- Example 2 -----------------------------------------\n\n// use clearParams() method to clear the parameters set by the neededParams() method.\njObj.clearParams();\n\nconsole.log(JSON.stringify(jObj.exec_query()));\n\n/*\n It will match the condition and return all the fields form the json object as we have cleared the parameters set for the jproc object.\n Output:\n -------\n [\n  {\n    \"name\": \"name_2\",\n    \"age\": 20,\n    \"details\": {\n      \"id\": \"iuefibe8362873287\",\n      \"location\": \"London\",\n      \"company\": \"abc\",\n      \"keywords\": [\n\t\"test1\",\n\t\"test2\",\n\t\"test3\"\n      ]\n    }\n  },\n  {\n    \"name\": \"name_3\",\n    \"age\": 19,\n    \"details\": {\n      \"id\": \"iwhiuvwi766579\",\n      \"location\": \"New York\",\n      \"company\": \"xyz\",\n      \"keywords\": [\n\t\"test1\",\n\t\"test2\",\n\t\"test3\"\n      ]\n    }\n  }\n]\n*/\n// ------------------------------- End of Example 2 ---------------------------------\n\n\n// ------------------------------- Example 3 ----------------------------------------\n\njObj.neededParams([\"name\", \"details.id\", \"details.location\"]);\n\n// Use clearQuery() method to clear existing query for the jproc object.\njObj.clearQuery();\n\nconsole.log(JSON.stringify(jObj.exec_query()));\n\n/*\n It doesn't match the condition as we have cleared the query and returns the fields form all the json elements for the array\n that are specified in the neededParams() method before.\nOutput:\n-------\n[\n  {\n    \"name\": \"name_1\",\n    \"id\": \"hvnakds2342349\",\n    \"location\": \"London\"\n  },\n  {\n    \"name\": \"name_2\",\n    \"id\": \"iuefibe8362873287\",\n    \"location\": \"London\"\n  },\n  {\n    \"name\": \"name_3\",\n    \"id\": \"iwhiuvwi766579\",\n    \"location\": \"New York\"\n  },\n  {\n    \"name\": \"name_4\",\n    \"id\": \"wuwcuwey652362\",\n    \"location\": \"Iraq\"\n  }\n]\n*/\n// ------------------------------ End of Example 3 ---------------------------------\n\n\n// ------------------------------ Example 4 ----------------------------------------\n\njObj.clearQuery();\njObj.clearParams();\n\nconsole.log(JSON.stringify(jObj.exec_query()));\n\n/*\nThis will throw error as we have cleared both parameters and query.\n*/\n// ------------------------------ End of Example 4 ---------------------------------\n\n```\n\n## Jproc-cli-usage\n\nJproc cli can read from a file using `--file` flag\n```bash\njproc --file=\"test.json\" --query=\"(age \u003e= 20 || (age \u003e 18 \u0026\u0026 details.company = 'xyz')) \u0026\u0026 (details.location = 'London' || details.location = 'New Yo\nrk')\"\n```\nOutput:\n```bash\n[\n  {\n    name: 'name_2',\n    age: 20,\n    details: {\n      id: 'iuefibe8362873287',\n      location: 'London',\n      company: 'abc',\n      keywords: [Array]\n    }\n  },\n  {\n    name: 'name_3',\n    age: 19,\n    details: {\n      id: 'iwhiuvwi766579',\n      location: 'New York',\n      company: 'xyz',\n      keywords: [Array]\n    }\n  }\n]\n```\n\nAlternatively, json outputs from other applications can be piped to jproc\n```bash\nstto --json redis | jproc --params=\"ext\",\"code\",\"file_count\" --query=\"line_count \u003e 200 \u0026\u0026 file_count \u003c 5\"\n```\n\nOutput:\n```bash\n[\n  { ext: 'markdown', code: 176, file_count: 1 },\n  { ext: 'm4', code: 669, file_count: 1 },\n  { ext: 'vcxproj.filters', code: 446, file_count: 4 },\n  { ext: 'vcxproj', code: 1412, file_count: 4 }\n]\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmainak55512%2Fjsonprocessor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmainak55512%2Fjsonprocessor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmainak55512%2Fjsonprocessor/lists"}