{"id":24443537,"url":"https://github.com/shaolang/jaqex","last_synced_at":"2025-04-12T21:27:32.164Z","repository":{"id":264021427,"uuid":"891974807","full_name":"shaolang/jaqex","owner":"shaolang","description":"Elixir wrapper for jaq","archived":false,"fork":false,"pushed_at":"2024-12-09T03:57:22.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-21T07:09:26.288Z","etag":null,"topics":["elixir","jaq","jq","json","rust"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/jaqex/","language":"Elixir","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/shaolang.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":"2024-11-21T09:43:11.000Z","updated_at":"2024-12-09T03:57:25.000Z","dependencies_parsed_at":"2024-11-21T15:45:43.595Z","dependency_job_id":null,"html_url":"https://github.com/shaolang/jaqex","commit_stats":null,"previous_names":["shaolang/jaqex"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaolang%2Fjaqex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaolang%2Fjaqex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaolang%2Fjaqex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shaolang%2Fjaqex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shaolang","download_url":"https://codeload.github.com/shaolang/jaqex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248633659,"owners_count":21136898,"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":["elixir","jaq","jq","json","rust"],"created_at":"2025-01-20T22:16:02.672Z","updated_at":"2025-04-12T21:27:32.145Z","avatar_url":"https://github.com/shaolang.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jaqex\nElixir wrapper for [jaq](https://github.com/01mf02/jaq), a [jq](https://jqlang.github.io/jq/)\nclone focused on correctness, speed, and simplicity implemented in Rust.\n\nUnlike other jq wrappers, this doesn't require jq to be installed/available in `$PATH`:\nJaqex uses [rustler](https://hexdocs.pm/rustler/) to implement the NIFs to jaq.\nAnd because Jaqex uses jaq, certain jq features like SQL-style operators aren't available.\nPlease refer to [jaq's README \"differences between jq and jaq\"][diff]\nfor more information. Despite such differences, jaq should still be useful in most\nscenarios, especially in the succintness in filtering/transforming JSON.\n\nThe following demonstrates the difference between using Elixir/Jason and Jaqex. Assuming\nwe have transform the following JSON doc from this:\n\n```json\n{\n    \"ticker\": \"AAPL\",\n    \"adjusted\": true,\n    \"prices\": [\n        {\"o\": 229.52, \"h\": 229.65, \"l\": 223.74, \"c\": 226.21, \"d\": \"2024-10-01\"},\n        {\"o\": 225.89, \"h\": 227.37, \"l\": 223.02, \"c\": 226.78, \"d\": \"2024-10-02\"}\n    ]\n}\n```\n\nTo this:\n\n```elixir\n[\n    %{\n        \"open\" =\u003e 229.52, \"high\": 229.65, \"low\" =\u003e 223.74, \"close\" =\u003e 226.21,\n        \"date\" =\u003e \"2024-10-01\", \"ticker\" =\u003e \"AAPL\", \"adjusted\": true\n    },\n    %{\n        \"open\" =\u003e 225.89, \"high\": 227.37, \"low\" =\u003e 223.02, \"close\" =\u003e 226.78,\n        \"date\" =\u003e \"2024-10-02\", \"ticker\" =\u003e \"AAPL\", \"adjusted\": true\n   },\n]\n```\n\nThe following shows how it's done using Elixir and Jason:\n\n```elixir\ndoc = Jason.decode!(json_string)    # assuming the contents are in json_string\nrenames = %{\"o\" =\u003e \"open\", \"h\" =\u003e \"high\", \"l\" =\u003e \"low\", \"c\" =\u003e \"close\", \"d\" =\u003e \"date\"}\nadditions = Map.take(doc, [\"ticker\", \"adjusted\"])\n\nresult =\n    doc[\"prices\"]\n    |\u003e Stream.map(fn m -\u003e\n        renames |\u003e Stream.map(fn {original, new_name} -\u003e {new_name, m[original]} end)\n    end)\n    |\u003e Stream.map(\u0026Map.new/1)\n    |\u003e Enum.map(\u0026Map.merge(\u00261, additions))\n```\n\nComparing that with using Jaqex:\n\n```elixir\nresult = Jaqex.filter!(\n    json_string,\n    \"[. as $root | .prices[] |\n        {open: .o, high: .h, low: .l, close: .c,\n         date: .d, ticker: $root.ticker, adjusted: $root.adjusted}\n    ]\"\n)\n```\n\nJaq/jq filters make transformations as such straightforward.\n\n## Installation\n\nAdd `jaqex` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:jaqex, \"~\u003e 0.1.2\"}\n  ]\nend\n```\n\n## Copyright and License\nCopyright © 2024, Shaolang Ai\n\nDistributed under the MIT License\n\n[diff]: https://github.com/01mf02/jaq/blob/main/README.md#differences-between-jq-and-jaq\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaolang%2Fjaqex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshaolang%2Fjaqex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshaolang%2Fjaqex/lists"}