Skip to content

1frag/ijq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IJQ

Overview

From stackoverflow you can find that tools like jq or json_pp will beatify output

curl https://petstore.swagger.io/v2/pet/1 | jq

but if we add -i (Include the HTTP response headers) option in curl command then command failed

$ curl https://petstore.swagger.io/v2/pet/1 -i | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138    0   138    0     0    100      0 --:--:--  0:00:01 --:--:--   100
parse error: Invalid numeric literal at line 1, column 7

How to prevent failure? Use ijq!

Install

git clone git@github.com:1frag/ijq.git
cd ijq
pip install -e .

Usage

curl -i https://petstore.swagger.io/v2/pet/1 | ijq

Output:

HTTP/2 200 
date: Wed, 26 Jul 2023 16:35:50 GMT
content-type: application/json
access-control-allow-origin: *
access-control-allow-methods: GET, POST, DELETE, PUT
access-control-allow-headers: Content-Type, api_key, Authorization
server: Jetty(9.2.9.v20150224)
{
    "category": {
        "id": 1,
        "name": "string"
    },
    "id": 1,
    "name": "doggie",
    "photoUrls": [
        "string"
    ],
    "status": "available",
    "tags": [
        {
            "id": 1,
            "name": "string"
        }
    ]
}

About

Display json beautifully among text

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages