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

how to expand at a particular object/array index #10

Open nelsieborja opened 1 year ago

nelsieborja commented 1 year ago

Is there a way to support expanding at a particular index?

Given the following values:

// Array
[
  {"key0": {...} },
  {"key1": {...} },
]

// Object
{
  "key0": {
    "key0": {...},
    "key1": {...}
  } ,
  "key1": "value1" ,
}

// Mixed
{
  "key0": [
    {...},
  ],
  "key1": "value1" ,
}

Say I want the first entry from the first level to be expanded, would it be possible to achieve this by passing something like expanded={1.1}?

jaywcjlove commented 1 year ago

@nelsieborja Do you want to collapse an object or array by default?

https://github.com/uiwjs/react-json-view/blob/6e152b84329b29006dee5828a9a7e919ad3e07ff/core/src/index.tsx#L52-L53