react-json-inspector icon indicating copy to clipboard operation
react-json-inspector copied to clipboard

[Feature Request] add option to hide root node

Open rutsky opened this issue 10 years ago • 5 comments

Root node is something artificial/virtual in JSON documents, it would be nice to be able to hide it.

rutsky avatar Sep 08 '15 13:09 rutsky

It's been some time, but I would like to propose a CSS solution, there's a modifier on the root leaf element, check for json-inspector__leaf_root. Does that sound like a plausible solution?

Lapple avatar Jan 18 '16 09:01 Lapple

I think CSS solution would be enough for this feature.

Such solution is hackish, because requires to attach external CSS to React component (and use implementation details: json-inspector__leaf_root), but this feature is in some way hakish too: it will work only if root object is object or list, and it doesn't make sense for other types of root object.

Perhaps you can document how this feature can be resolved using CSS, e.g. provide example in docs? (I believe in addition to hiding root node label, subelements indentation should be removed)

rutsky avatar Jan 18 '16 13:01 rutsky

+1 also interested in doing this in a cleaner way

swillard-r7 avatar Mar 03 '16 16:03 swillard-r7

this css will hide the first root and colon. verified it woks on objects and arrays.

.json-inspector > .json-inspector__leaf_root > .json-inspector__line > .json-inspector__key {
    display: none;
}

skhavari avatar Apr 13 '16 02:04 skhavari

We are already hiding it using CSS but I agree on that it would be great to have it as an option.

cmdelatorre avatar Sep 22 '17 18:09 cmdelatorre