{"id":13705090,"url":"https://github.com/fiatjaf/jq-web","last_synced_at":"2025-04-13T07:50:33.733Z","repository":{"id":45457894,"uuid":"90417462","full_name":"fiatjaf/jq-web","owner":"fiatjaf","description":"jq in the browser with emscripten.","archived":false,"fork":false,"pushed_at":"2025-03-19T22:19:15.000Z","size":11742,"stargazers_count":333,"open_issues_count":11,"forks_count":31,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-04T06:36:55.677Z","etag":null,"topics":["emscripten","jq","json"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fiatjaf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-05-05T21:24:05.000Z","updated_at":"2025-03-31T07:49:34.000Z","dependencies_parsed_at":"2024-06-18T15:32:44.369Z","dependency_job_id":"79f3f00a-0d83-48dd-afe3-2fb4560f8ee6","html_url":"https://github.com/fiatjaf/jq-web","commit_stats":{"total_commits":53,"total_committers":6,"mean_commits":8.833333333333334,"dds":"0.26415094339622647","last_synced_commit":"cf1752cfaee4b197063b879971892ff06677dd8c"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiatjaf%2Fjq-web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiatjaf%2Fjq-web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiatjaf%2Fjq-web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fiatjaf%2Fjq-web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fiatjaf","download_url":"https://codeload.github.com/fiatjaf/jq-web/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681494,"owners_count":21144700,"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":["emscripten","jq","json"],"created_at":"2024-08-02T22:00:31.458Z","updated_at":"2025-04-13T07:50:33.706Z","avatar_url":"https://github.com/fiatjaf.png","language":"JavaScript","funding_links":[],"categories":["Projects","Uncategorized","Data Munging","项目推荐"],"sub_categories":["Data processing","Uncategorized","数据处理"],"readme":"[![npm badge](https://img.shields.io/npm/v/jq-web.svg)](https://www.npmjs.com/package/jq-web) [![Mentioned in Awesome jq](https://awesome.re/mentioned-badge.svg)](https://github.com/fiatjaf/awesome-jq)\n\n# jq-web\n\nThis is a WebAssembly build of [jq](https://github.com/jqlang/jq), the command-line JSON processor.\n\nIt runs in the browser.\n\n### Installation and use\n\n```\nnpm install jq-web\n```\n\n```js\nvar jq = require('jq-web');\n\njq.then( jq =\u003e jq.json({\n  a: {\n    big: {\n      json: [\n        'full',\n        'of',\n        'important',\n        'things'\n      ]\n    }\n  }\n}, '.a.big.json | [\"empty\", .[1], \"useless\", .[3]] | join(\" \")')\n```\n\nThe code above returns the string `\"empty of useless things\"`.\n\nYou could do the same using the promised API with `jq.promised.json({...}).then(result =\u003e {})`. That is useful if you're loading a `.mem` or `.wasm` file, as the library won't return the correct results until these files are asynchronously fetched by the Emscripten runtime.\n\n### Webpack issues\n\n#### `fs`\nThe Emscripten runtime will try to `require` the `fs` module, and if it fails it will resort to an in-memory filesystem (almost no use of that is made of the library, but it is needed somehow). In Browserify there's a default `{}` that corresponds to the `fs` module, but in Webpack you must [declare it as an empty module](https://github.com/fiatjaf/jq-web/issues/5#issuecomment-342694955).\n\n#### 404 error when loading `.wasm` files\nBy default projects compiled with Emscripten look for `.wasm` files in the same directory that the `.js` file is run from. This causes issues when using webpack because name of the `.wasm` file is altered with a hash and can be placed in a different directory. To fix this problem you can use the [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin) to copy the `jq.wasm` file to the same directory that the webpack bundle is placed.\n\n## Reference\n\n`jq-web` exports a promise that resolves to an object with `json` and `raw` methods.\n\n`jq.json(\u003cobject\u003e, \u003cfilter\u003e) \u003cobject\u003e` will take a Javascript object, or scalar, whatever, and dump it to JSON, then it will return whatever your filter outputs and try to convert that into a JS object.\n\n`jq.raw(\u003cjson-string\u003e, \u003cfilter\u003e, \u003cflags\u003e) \u003craw-output\u003e` will take a string that will be passed as it is to jq (like if you were doing `echo '\u003cjson-string\u003e' | jq \u003cfilter\u003e` on the command line) then return a string with the raw STDOUT response.\n\n## Build\n\n1. Install Emscripten. There have been several API changes over time; version 3.1.31\nis known to work.\n2. Clone this repository, and `cd` into it.\n3. `make`\n    * This may take a while if you have never run Emscripten before.\n\n## Test\nA handful of tests exist in `test.js`. These are a good place to start when verifying a build.\nTo run them, do `make test`.\n\nYou can test browser functionality by running:\n`./node_modules/live-server/live-server.js --open=\"index.html\"`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiatjaf%2Fjq-web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffiatjaf%2Fjq-web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffiatjaf%2Fjq-web/lists"}