tulios / json-viewer

It is a Chrome extension for printing JSON and JSONP.
https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh
MIT License
3.3k stars 675 forks source link

Option to have compact view for small arrays/objects #291

Open jribbens opened 3 years ago

jribbens commented 3 years ago

It would be nice to have an option to have a compact display for small arrays/objects, e.g. to display "foo": [1, 2, 3] as "foo": [1, 2, 3] on one line rather than the only choices being "collapsed and none of the contents visible" or "expanded and taking up many lines unnecessarily".

jsejcksn commented 3 years ago

This seems like a reasonable idea. Like many ideas, the implementation is more complex than the description.

for small arrays/objects

@jribbens As a starting point to help someone who might want to implement it: what is your definition of "small" (expressed in terms of code)?

jribbens commented 3 years ago

Well the easiest way would be to simply say something like "less than 40 characters when expressed as JSON", or a slightly more complicated way would be "when expressed as JSON, does not wrap onto the next line in the current browser window" (or indeed both rules at once). Plus perhaps "does not contain any objects or arrays".

bora89 commented 1 year ago

Seems like it has not implemented in 2023, that would be great to see one-line display view. How to implement ?

jribbens commented 1 year ago

@bora89 Bit cheeky of me, but due to lack of progress on this I went and wrote my own JSON extension from scratch which fixes this and all the other issues I had with this and other existing JSON extensions. Also my one is the only one that can cope with large JSON files (up to 500MB...) :-) https://chrome.google.com/webstore/detail/json-wrangler/kgmhfbhlcdhjldpbjgoaljbpendgkede?hl=en-GB

bora89 commented 1 year ago

@jribbens Great, will check it out!