[Feature Request] Hide Root

Open
#84 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
react, typescript
Domain
frontend

Research direction

Start by tracing the JsonView component's value-rendering path, especially how array and object roots are displayed. Define the behavior for hiding the root while preserving the existing nested rendering and verify it for both arrays and objects using the examples in the issue; no test file is named in the payload.

Written by the indexing model from the issue text.

Description

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)

Dominant language
TypeScript
Stars
420
Forks
24
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uiwjs/react-json-view

All issues in uiwjs/react-json-view

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.