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

Is there a way to not showindexes of arrays?

Open globetro opened this issue 1 year ago • 4 comments

I'd ideally like to be able to just select text to copy/paste (versus relying on the inline-copy button), and showing the indexes makes it not possible.

globetro avatar Feb 03 '24 18:02 globetro

You can use something like this

    <JsonView >
        <JsonView.Colon render={() => <span />}/>
        <JsonView.KeyName 
        render={({ ...props }, { type, value, keyName }) => {
          if (!isNaN(parseFloat(keyName))) {
            return <span />
          }
          return <span {...props}>{keyName}:</span>
        }}
        />
  </JsonView>

If there are numeric keys out of array, then it will not work

morgothko avatar Feb 13 '24 17:02 morgothko

+1 to this, the proposed workaround doesn't really work that well

antipopp avatar Oct 10 '24 14:10 antipopp

@globetro @antipopp @morgothko Upgrade v2.0.0-alpha.28

https://github.com/uiwjs/react-json-view/blob/18a9334a17fb2f23c9d30b7c1c9e0cdabd7eb965/core/README.md?plain=1#L687-L710

image

jaywcjlove avatar Oct 16 '24 19:10 jaywcjlove

A simple boolean parameter would be excellent, something like displayArrayIndexes.

Also, that workaround does not pass VS Code linting, complains about the type:

Image

nobodo avatar Mar 11 '25 09:03 nobodo