{"id":16306147,"url":"https://github.com/gfx/hj","last_synced_at":"2025-03-22T20:33:00.171Z","repository":{"id":44762053,"uuid":"451742411","full_name":"gfx/hj","owner":"gfx","description":"A command line tool to convert HTTP/1 style text to JSON","archived":false,"fork":false,"pushed_at":"2022-02-16T05:31:20.000Z","size":28,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-11T21:09:54.601Z","etag":null,"topics":["curl","http-tools"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gfx.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}},"created_at":"2022-01-25T05:06:19.000Z","updated_at":"2024-03-24T09:30:37.000Z","dependencies_parsed_at":"2022-08-29T22:00:09.430Z","dependency_job_id":null,"html_url":"https://github.com/gfx/hj","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx%2Fhj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx%2Fhj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx%2Fhj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gfx%2Fhj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gfx","download_url":"https://codeload.github.com/gfx/hj/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221839139,"owners_count":16889590,"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":["curl","http-tools"],"created_at":"2024-10-10T21:09:46.852Z","updated_at":"2024-10-28T14:16:43.772Z","avatar_url":"https://github.com/gfx.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hj [![CI](https://github.com/gfx/hj/actions/workflows/ci.yml/badge.svg)](https://github.com/gfx/hj/actions/workflows/ci.yml)\n\n**hj** is a command line tool to convert HTTP/1-style text into JSON.\n\nThis command is inspired by [yusukebe/rj](https://github.com/yusukebe/rj), which is a standalone HTTP client that shows HTTP responses in JSON. On the other hand, this command is not an HTTP client but a simple text filter that translates a result of an external HTTP client such as curl(1).\n\n## Synopsis\n\nSimple usage with **curl(1)**:\n\n```shell\n# -sv is required to output HTTP response headers.\n$ curl -sv https://httpbin.org/get 2\u003e\u00261 | hj | jq .\n```\n\nThe output may be:\n\n```json\n{\n  \"protocol\": \"HTTP/1.1\",\n  \"status_code\": 200,\n  \"headers\": {\n    \"accept-ranges\": \"bytes\",\n    \"age\": \"417384\",\n    \"cache-control\": \"max-age=604800\",\n    \"content-type\": \"text/html; charset=UTF-8\",\n    \"date\": \"Tue, 25 Jan 2022 04:28:00 GMT\",\n    \"etag\": \"\\\"3147526947\\\"\",\n    \"expires\": \"Tue, 01 Feb 2022 04:28:00 GMT\",\n    \"last-modified\": \"Thu, 17 Oct 2019 07:18:26 GMT\",\n    \"server\": \"ECS (sab/56BC)\",\n    \"vary\": \"Accept-Encoding\",\n    \"x-cache\": \"HIT\",\n    \"content-length\": \"1256\"\n  },\n  \"content\": \"\u003c!doctype html\u003e\\n\u003chtml\u003e\\n\u003chead\u003e\\n    \u003ctitle\u003eExample Domain\u003c/title\u003e\\n\\n    \u003cmeta charset=\\\"utf-8\\\" /\u003e\\n    \u003cmeta http-equiv=\\\"Content-type\\\" content=\\\"text/html; charset=utf-8\\\" /\u003e\\n    \u003cmeta name=\\\"viewport\\\" content=\\\"width=device-width, initial-scale=1\\\" /\u003e\\n    \u003cstyle type=\\\"text/css\\\"\u003e\\n    body {\\n        background-color: #f0f0f2;\\n        margin: 0;\\n        padding: 0;\\n        font-family: -apple-system, system-ui, BlinkMacSystemFont, \\\"Segoe UI\\\", \\\"Open Sans\\\", \\\"Helvetica Neue\\\", Helvetica, Arial, sans-serif;\\n        \\n    }\\n    div {\\n        width: 600px;\\n        margin: 5em auto;\\n        padding: 2em;\\n        background-color: #fdfdff;\\n        border-radius: 0.5em;\\n        box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\\n    }\\n    a:link, a:visited {\\n        color: #38488f;\\n        text-decoration: none;\\n    }\\n    @media (max-width: 700px) {\\n        div {\\n            margin: 0 auto;\\n            width: auto;\\n        }\\n    }\\n    \u003c/style\u003e    \\n\u003c/head\u003e\\n\\n\u003cbody\u003e\\n\u003cdiv\u003e\\n    \u003ch1\u003eExample Domain\u003c/h1\u003e\\n    \u003cp\u003eThis domain is for use in illustrative examples in documents. You may use this\\n    domain in literature without prior coordination or asking for permission.\u003c/p\u003e\\n    \u003cp\u003e\u003ca href=\\\"https://www.iana.org/domains/example\\\"\u003eMore information...\u003c/a\u003e\u003c/p\u003e\\n\u003c/div\u003e\\n\u003c/body\u003e\\n\u003c/html\u003e\\n\"\n}\n```\n\nIf the response is JSON (`content-type: application/json`), its content is automatically parsed as JSON:\n\n```shell\ncurl -sv https://jsonplaceholder.typicode.com/todos/1 2\u003e\u00261 | hj | jq .\n```\n\noutput:\n\n```json\n{\n  \"protocol\": \"HTTP/1.1\",\n  \"status_code\": 200,\n  \"headers\": {\n    \"date\": \"Tue, 25 Jan 2022 04:57:52 GMT\",\n    \"content-type\": \"application/json; charset=utf-8\",\n    \"content-length\": \"83\",\n    \"connection\": \"keep-alive\",\n    \"x-powered-by\": \"Express\",\n    \"x-ratelimit-limit\": \"1000\",\n    \"x-ratelimit-remaining\": \"999\",\n    \"x-ratelimit-reset\": \"1631494143\",\n    \"vary\": \"Origin, Accept-Encoding\",\n    \"access-control-allow-credentials\": \"true\",\n    \"cache-control\": \"max-age=43200\",\n    \"pragma\": \"no-cache\",\n    \"expires\": \"-1\",\n    \"x-content-type-options\": \"nosniff\",\n    \"etag\": \"W/\\\"53-hfEnumeNh6YirfjyjaujcOPPT+s\\\"\",\n    \"via\": \"1.1 vegur\",\n    \"cf-cache-status\": \"HIT\",\n    \"age\": \"13133\",\n    \"accept-ranges\": \"bytes\",\n    \"expect-ct\": \"max-age=604800, report-uri=\\\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\\\"\",\n    \"report-to\": \"{\\\"endpoints\\\":[{\\\"url\\\":\\\"https:\\\\/\\\\/a.nel.cloudflare.com\\\\/report\\\\/v3?s=kfDw3zHT7KgD4%2FmRBWFv5gYnwzVVSqFH5N%2F9sTmdI425jb9mZyZggJNoeaYF2%2B%2FdEQ57JdVJggqDJZSRKt5YX%2BStzgoYRGmSwcsQ5M%2Bd1vD9rzT72hrwQfh62ZXPa01QSJxhEpyJUmf7y8BVuagT\\\"}],\\\"group\\\":\\\"cf-nel\\\",\\\"max_age\\\":604800}\",\n    \"nel\": \"{\\\"success_fraction\\\":0,\\\"report_to\\\":\\\"cf-nel\\\",\\\"max_age\\\":604800}\",\n    \"server\": \"cloudflare\",\n    \"cf-ray\": \"6d2eec5508f10ac0-NRT\",\n    \"alt-svc\": \"h3=\\\":443\\\"; ma=86400, h3-29=\\\":443\\\"; ma=86400\"\n  },\n  \"content\": {\n    \"completed\": false,\n    \"userId\": 1,\n    \"title\": \"delectus aut autem\",\n    \"id\": 1\n  }\n}\n```\n\n## Install\n\ncargo(1) and rustc(1) (\u003e= v1.58) are required to install.\n\n### Via Crate.io\n\nhttps://crates.io/crates/hj\n\n```shell\ncargo install hj\n```\n\n### Local Development\n\n```shell\ncargo install --path .\n```\n\n## Supported Commands\n\n* curl - https://curl.se/\n  * `-sv` options are required for `hj`\n* h2o-httplicent - https://github.com/h2o/h2o/\n* Any of HTTP/1 style texts\n\n## License\n\nCopyright 2022 FUJI Goro.\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfx%2Fhj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgfx%2Fhj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgfx%2Fhj/lists"}