vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

Formatting json in requests

Open Meir017 opened this issue 8 years ago • 15 comments

Would it be possible to embed the json editor for the content of the request when specifing Content-Type: application/json ?

something like this: image

Meir017 avatar Nov 09 '17 15:11 Meir017

@Meir017 nice suggestion, I will consider a nice way to implement it and other cases like xml

Huachao avatar Nov 10 '17 02:11 Huachao

@Meir017 @flanakin @dpfg do you think if the input json request body will be formatted when you type(the JSON maybe incomplete then) can meet your requirements, or do you need anything else?

Huachao avatar Jan 23 '18 08:01 Huachao

Syntax highlighting would also be nice to have. When you edit markdown in vscode and put code snippet with specified syntax you get highlighting + indentation on typing. Would be wonderful to have the same.

dpfg avatar Jan 23 '18 09:01 dpfg

@dpfg @Meir017 @flanakin I have supported the request body(JSON and XML only) automatically highlight like following: image

Huachao avatar Jan 24 '18 10:01 Huachao

This looks amazing!

Is it possible to actually use a json editor just for the request body section? this will provide better autocomplete, something like this: image

Meir017 avatar Jan 24 '18 19:01 Meir017

@Meir017 use json editor as request body section is a limitation of Microsoft/vscode#1751. So currently not possible, and I will try to use own ways to support auto format

Huachao avatar Jan 25 '18 02:01 Huachao

@Meir017 @dpfg @flanakin @vivekchauhan you can try the json/xml request body highlight feature in latest version 0.17.0

Huachao avatar Jan 30 '18 07:01 Huachao

Looks great

Meir017 avatar Jan 30 '18 14:01 Meir017

Thanks, looks really good!

dpfg avatar Jan 30 '18 18:01 dpfg

@Huachao take a look at this - https://youtu.be/7Eh_l7jEcCo?t=24m6s the aspnet team is working on Razor support in vscode which means multiple languages in the same file

Meir017 avatar Aug 07 '18 17:08 Meir017

@Meir017 thanks, I will investiate this later.

Huachao avatar Aug 08 '18 06:08 Huachao

Hey thank you for this excellent extension really loving it.

Quick question bc I cannot figure how should i properly use it to get json formatting - maybe I have something misconfigured in my environment.

I like how everything works when I use .http file extension in regards to syntax highlighting. Here i get the "Send Request" action when I hover over a particular request. But this doesnt auto-format and ident the JSON body in the REQUESTS.

If i switch to .json file extension, now the json bodies of request are properly formatted, but I loose the "Send Request" action on hovering over the request.

So probably I am doing something stupid but I canot figure out how to merge the tow - can you please clarify what is the correct procedure to use this extension and enable pretty-formatting the request body. Also to note I use prettier in my project, I dont know if that makes a difference.

Either way thanks a lot for your hard work.

gcloeval avatar Dec 22 '18 14:12 gcloeval

@gcloeval auto formatting request body is not supported yet, sorry for the inconvenience. I will consider this carefully.

Huachao avatar Dec 24 '18 01:12 Huachao

for xml requests, if you use XML Tools extension you can select the text and run "Format as XML" . I don't know if something similar exists for json

xiorcal avatar Mar 14 '19 13:03 xiorcal

no updates?

MariuzM avatar Sep 07 '23 16:09 MariuzM