json-viewer icon indicating copy to clipboard operation
json-viewer copied to clipboard

Option to have compact view for small arrays/objects

Open jribbens opened this issue 3 years ago • 5 comments

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".

jribbens avatar May 18 '21 12:05 jribbens

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)?

jsejcksn avatar Jun 29 '21 04:06 jsejcksn

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".

jribbens avatar Jun 29 '21 11:06 jribbens

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

bora89 avatar Mar 03 '23 05:03 bora89

@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

jribbens avatar Mar 03 '23 14:03 jribbens

@jribbens Great, will check it out!

bora89 avatar Jun 06 '23 09:06 bora89