httpx icon indicating copy to clipboard operation
httpx copied to clipboard

JSON output fields to update - dash with underscore

Open ehsandeep opened this issue 3 years ago • 0 comments

Please describe your feature request:

To make json output easy to consume, json output fields that contains - (dash) can be replaced with _ (underscore)

Reference:

  • https://stackoverflow.com/questions/13869627/unable-to-access-json-property-with-dash
old json output
{
  "timestamp": "2022-08-30T17:10:01.284181+05:30",
  "hashes": {
    "body-md5": "4d1fdd73ba03f4b356813738a3ecddc6",
    "body-mmh3": "-563453106",
    "body-sha256": "b0029671f9197be963819748e9e2b824e0d175264743edffbc373b4a346558eb",
    "body-simhash": "12638153115695167406",
    "header-md5": "b458e3300de02b52700b133cd2748725",
    "header-mmh3": "1659750615",
    "header-sha256": "3a4ba0a5c0de9d4a62a5fc0e0e42369455a29bd8ddad311ede3d00af53106b5d",
    "header-simhash": "9814140797135303997"
  },
  "port": "443",
  "url": "https://google.com:443",
  "input": "google.com",
  "title": "Google",
  "scheme": "https",
  "webserver": "gws",
  "content-type": "text/html",
  "method": "GET",
  "host": "142.250.183.78",
  "path": "/",
  "favicon-mmh3": "708578229",
  "final-url": "https://www.google.com/",
  "response-time": "2.710661709s",
  "chain-status-codes": [
    301,
    200
  ],
  "a": [
    "142.250.183.78",
    "2404:6800:4009:80b::200e"
  ],
  "words": 3747,
  "lines": 240,
  "status-code": 200,
  "content-length": 164793,
  "failed": false
}

new json output
{
  "timestamp": "2022_08_30T17:10:01.284181+05:30",
  "hashes": {
    "body_md5": "4d1fdd73ba03f4b356813738a3ecddc6",
    "body_mmh3": "_563453106",
    "body_sha256": "b0029671f9197be963819748e9e2b824e0d175264743edffbc373b4a346558eb",
    "body_simhash": "12638153115695167406",
    "header_md5": "b458e3300de02b52700b133cd2748725",
    "header_mmh3": "1659750615",
    "header_sha256": "3a4ba0a5c0de9d4a62a5fc0e0e42369455a29bd8ddad311ede3d00af53106b5d",
    "header_simhash": "9814140797135303997"
  },
  "port": "443",
  "url": "https://google.com:443",
  "input": "google.com",
  "title": "Google",
  "scheme": "https",
  "webserver": "gws",
  "content_type": "text/html",
  "method": "GET",
  "host": "142.250.183.78",
  "path": "/",
  "favicon_mmh3": "708578229",
  "final_url": "https://www.google.com/",
  "response_time": "2.710661709s",
  "chain_status_codes": [
    301,
    200
  ],
  "a": [
    "142.250.183.78",
    "2404:6800:4009:80b::200e"
  ],
  "words": 3747,
  "lines": 240,
  "status_code": 200,
  "content_length": 164793,
  "failed": false
}

ehsandeep avatar Aug 30 '22 11:08 ehsandeep