cli icon indicating copy to clipboard operation
cli copied to clipboard

JSON properties are shuffled

Open imclint21 opened this issue 1 year ago • 1 comments

Hi,

I just execute this:

http http://localhost:9021/api/development

And i get this output:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Sun, 19 May 2024 10:58:34 GMT
Server: Kestrel
Transfer-Encoding: chunked

[
    {
        "allowedIps": null,
        "configurationFile": "/tmp/proxies/ups1.conf",
        "createdAt": "2024-05-18T18:13:44.204+00:00",
        "id": "60ac07ef-5a80-4352-8b03-2ab8f68ef68f",
        "password": "string",
        "port": 1001,
        "updatedAt": "2024-05-18T18:13:44.204+00:00",
        "upstream": "ups1",
        "username": "string"
    }
]

I don't understand why properties are shuffled, should be like this:

[
  {
    "id": "60ac07ef-5a80-4352-8b03-2ab8f68ef68f",
    "createdAt": "2024-05-18T18:13:44.204+00:00",
    "updatedAt": "2024-05-18T18:13:44.204+00:00",
    "upstream": "ups1",
    "port": 1001,
    "username": "string",
    "password": "string",
    "allowedIps": null,
    "configurationFile": "/tmp/proxies/ups1.conf"
  }
]

Regards

imclint21 avatar May 19 '24 11:05 imclint21

They are not shuffled, they are alphabetically sorted.

onlined avatar May 19 '24 23:05 onlined

Ah I see, why touch it tho?

imclint21 avatar May 21 '24 10:05 imclint21

I don't know, just wrote thinking it might be helpful.

onlined avatar May 21 '24 14:05 onlined

You can try --unsorted option, for more detail: https://httpie.io/docs/cli/format-options

onlined avatar May 21 '24 14:05 onlined

As clarified in the thread, this is not an issue but clearly what was intended by the author. It was a UX decision and it is understandable how you got confused. Two sides emerge for this:

  • A) Sorted render makes it easier to read by a human.
  • B) Unsorted render makes it easier to verify the content conformity from the backend developer PoV.

But as you found the workaround for this, I am inclined to close it.

Ousret avatar May 23 '24 03:05 Ousret