rest-book icon indicating copy to clipboard operation
rest-book copied to clipboard

add JSONView response renderer

Open RandomFractals opened this issue 3 years ago • 16 comments

for JSON response display with expand/collapse tree nodes for json documents, in addition to existing Data tab that should show formatted JSON doc.

see: https://github.com/tanhakabir/rest-book/issues/73#issuecomment-827007087

RandomFractals avatar Apr 26 '21 18:04 RandomFractals

@tanhakabir now that I know how to work that </> cell output renderer toggle, we can probably close this.

What I was looking for to see as a JSONView, which is one of the built-in mime type renderers :)

image

still would be nice to at least parse and format json data output in your custom Data tab:

image

RandomFractals avatar Apr 29 '21 02:04 RandomFractals

yeah! I would still like to see a prettified view of the data in the Data tab for the custom output

tanhakabir avatar Apr 29 '21 16:04 tanhakabir

I don't think we want to use online services for json view.

At the minimum, I think we should use null for replacer and 2 spaces when you stringify it in your custom data view.

vscode already has built-in color coded json renderer.

I suggest you do that and we close this ticket.

RandomFractals avatar May 20 '21 17:05 RandomFractals

Sorry I misunderstood a previous comment, I'll remove my previous post as it's confusing.

I feel a built in renderer would be the best as it makes the response easier to read instantly without extra steps of copy/pasting. I use RestClient a lot and the response is rendered appropriately. If we can combine the response rendering of RestClient with your notebooks I think you'd have a perfect extension.

asmith3006 avatar May 20 '21 20:05 asmith3006

@asmith3006 just to clarify this version of the JSON view doesn't work well for you?

recording (39)

tanhakabir avatar May 21 '21 16:05 tanhakabir

@tanhakabir can you format json data response in your default Data tab without switching to built-in json renderer?

I think that's what we are missing to avoid extra clicks to get to that picker, and be able to quickly view data returned in json format.

Personally, I don't care for color coded json as much as in built-in view, as long as I can read json response in Data tab, and copy/paste it elsewhere without running json reformat on it. That minimum change should work nicely for color blind folks like me who don't see those color coded highlights as well anyway.

Thanks!

RandomFractals avatar May 21 '21 16:05 RandomFractals

Good point! Sure!

tanhakabir avatar May 21 '21 16:05 tanhakabir

just an fyi I am using a restbook to test the leaflet map renderer I plan to work on. So far looks like we can use both just fine.

I just wish there was a way to set the default for some of those cell output mime types ...

leaflet-output-renderer

RandomFractals avatar May 24 '21 03:05 RandomFractals

@tanhakabir btw, you might want to try this: https://github.com/RandomFractals/vscode-data-table/issues/23#issuecomment-874833269

data-table-chicago-traffic

RandomFractals avatar Jul 06 '21 14:07 RandomFractals

cool!

tanhakabir avatar Jul 12 '21 18:07 tanhakabir

once you're happy with it, I can add your renderer as an optional dependency to my extension to view csvs

tanhakabir avatar Jul 12 '21 18:07 tanhakabir

good idea. I need to patch my stdout replacement and will let you know when that update is ready to use.

Thanks!

RandomFractals avatar Jul 12 '21 21:07 RandomFractals

@tanhakabir actually, you can add my data table renderer as a dependency for json and csv data display already.

I checked and my v1.1.0 should be able to parse and render both just fine.

see: https://github.com/RandomFractals/vscode-data-table/releases/tag/v1.1.0

RandomFractals avatar Jul 13 '21 14:07 RandomFractals

... now with geojson data display too :wink: https://github.com/RandomFractals/vscode-data-table/releases/tag/v1.3.0

world-rivers-geo-data-table

RandomFractals avatar Jul 20 '21 16:07 RandomFractals

I've used https://www.npmjs.com/package/react-json-view in the past with success. It should work in preact, possibly with preact-compat

Imo a tabular view of json data is domain specific towards data science work and isn't nearly as common as people working with traditional REST APIs, so (unlike some degree of sane formatting of JSON responses 😉 ) I don't feel that such functionality needs to be built in.

connor4312 avatar Jul 21 '21 04:07 connor4312

@connor4312 I think it would be best if vscode provided an api to integrate built-in json, xml and other text editor views in notebook cell renderers, so we can use them for uniform user experience and focus more on creating custom renderers like that data table, which I think with some work can be used by other devs for REST response views, not just data scientists.

I've seen a number of data tables rolled into different notebook platforms in vscode, R & Py, and some attempts to standardize that with varying results.

So, I disagree with your views on tabular data display. In fact, I am surprised vscode still doesn't have a built-in data table component extension authors can use for data display.

RandomFractals avatar Jul 21 '21 11:07 RandomFractals