mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[GH-ISSUE #4427] [feature]: Why can't the returned json format beautify? #1624
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#1624
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @wyouwd1 on GitHub (Oct 11, 2024).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/4427
Is there an existing issue for this?
Summary
The returned json format data cannot be beautified. I need to paste it into a text tool every time, which is a waste of time.
My version is: v2024.9.1
Why should this be worked on?
Tools should save efficiency.I remember it was working before, why doesn't it work after the update?
@liyasthomas commented on GitHub (Oct 11, 2024):
Can you provide instructions to reproduce this behaviour?
@wyouwd1 commented on GitHub (Oct 11, 2024):
I found that there are two situations when I request an interface, one that can be beautified and one that cannot be beautified. The following is an example that I provide that cannot be beautified.
//curl
curl --request POST
--url 'https://*****/aaa/asr/aaa?token=aaa'
--header 'content-type: application/json'
--header 'timestamp: 324342342342424'
--data '{
"url": "aaa.wav",
"smoothTextEnabled": true,
"encryptFileEnabled": false,
"unDeleteFlag": true,
}'
//return data
{"code":0,"message":"success","data":{"taskSeq":"ca138bae1c81084d0346b962ee5a4b2b_eN6"}}
@liyasthomas commented on GitHub (Oct 11, 2024):
Is this response appearing inside the "JSON" or "RAW" tab in Response panel?
@wyouwd1 commented on GitHub (Oct 11, 2024):
I think I know the reason. The content-type returned by this interface is text-plain; charset=UTF-8, which cannot be beautified automatically. In this case, shouldn't there be a manual beautification button? Isn't there such a button in the Body?
@wyouwd1 commented on GitHub (Oct 11, 2024):
Maybe you can consider beautifying automatically first, and if beautification fails, give a prompt on the status bar, together with the Status
@liyasthomas commented on GitHub (Oct 11, 2024):
Interesting observation. I wonder why JSON response has content-type: text-plain instead of application/json?
@wyouwd1 commented on GitHub (Oct 11, 2024):
I think the most important thing at the moment is to add the beautification button to the returned Raw.I can provide an example of the data returned by the interface.
[{"key":"server","value":"nginx"},{"key":"date","value":"Fri, 11 Oct 2024 02:47:45 GMT"},{"key":"content-type","value":"text/plain;charset=UTF-8"},{"key":"content-length","value":"88"},{"key":"connection","value":"keep-alive"},{"key":"x-backend-host","value":"0736:8090"},{"key":"x-gateway-host","value":"5130dfd8883e79b28bafe070a9a72a05a7209946266b6e5017dc365cbd74292d2f11d1121b62bab852e4d36722fa836f9eb1a6273c6c24c5c86aa47bd39bc8a9"}]
@liyasthomas commented on GitHub (Oct 11, 2024):
I'm afraid we can't prettify RAW data. RAW tab will render the exact raw data received from the server response, which could be a plain text, a rich media (image, video etc…), xml or any other formats.
I think the best possible solution is to enforce application/json content-type for responses, which will be automatically picked up by Hoppscotch to render the JSON tab with not only the prettified response but also enjoy other features like Filter using JSONPath Finder syntax, data schema generation etc.
I'd be happy to assist you with any other questions.
@wyouwd1 commented on GitHub (Oct 12, 2024):
If automatic beautification does not meet the needs, can we add a manual beautification button to the results to give users a choice? I see there is one in the Body. It should be easy to copy the function.
@kooper100 commented on GitHub (Dec 18, 2024):
The best possible solution is to fix everyone else's APIs...? Like that's not realistic at all. This is very annoying because I also have to copy and paste responses into a text editor to format properly. Please add a manual format button.