uiwjs / react-json-view

A React component for displaying and editing javascript arrays and JSON objects.
https://uiwjs.github.io/react-json-view/
MIT License
212 stars 12 forks source link

Is there a way to not showindexes of arrays? #32

Open globetro opened 8 months ago

globetro commented 8 months ago

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.

morgothko commented 8 months ago

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

antipopp commented 2 weeks ago

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

jaywcjlove commented 1 week ago

@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