Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
globetro opened this issue Feb 3, 2024 · 3 comments
Open

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

globetro opened this issue Feb 3, 2024 · 3 comments

Comments

@globetro
Copy link

globetro commented Feb 3, 2024

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
Copy link

morgothko commented Feb 13, 2024

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
Copy link

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

@jaywcjlove
Copy link
Member

jaywcjlove commented Oct 16, 2024

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

import React, { Fragment } from 'react';
import JsonView from '@uiw/react-json-view';
export default function Demo() {
const value = { data: ["123", 23] }
return (
<JsonView value={value} style={{ '--w-rjv-background-color': '#ffffff' }}>
<JsonView.Colon render={(props, { parentValue, value, keyName }) => {
if (Array.isArray(parentValue) && props.children == ":") {
return <span />
}
return <span {...props} />
}}/>
<JsonView.KeyName
render={({ ...props }, { type, parentValue, value, keyName }) => {
if (Array.isArray(parentValue) && Number.isFinite( props.children)) {
return <span />
}
return <span {...props} />
}}
/>
</JsonView>
)
}

image

github-actions bot pushed a commit that referenced this issue Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants