Skip to content

[Feature Request] Hide Root #84

Description

@eladavron

Hi
It would be nice to be able to 'hide' the root element.
So for example, for this object:

[
    {
        "foo": "bar",
        "lorem": 1
    },
    {
        "hi": "hello",
        "lorem": 2
    },
    {
        "etc": "etera",
        "lorem": 3
    }
]

Display just:

Image

or:
Image

I achieved similar behavior using:

if (Array.isArray(value)) {
  root.render(
    <div className="flex flex-col gap-2">
      {value.map((item, i) => (
        <JsonView
          key={i}
          value={item}
          collapsed={3}
          enableClipboard={false}
          displayDataTypes={false}
        />
      ))}
    </div>
  );
} else {
  root.render(
    <JsonView
      value={value}
      collapsed={3}
      enableClipboard={false}
      displayDataTypes={false}
    />
  );
}

but it would be nice to have a built-in feature to reduce code duplication and overhead.
(I guess there's no reason to limit it to just arrays, but that was my particular use case)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions