Skip to content

Commit

Permalink
Merge pull request #7227 from tibdex/master
Browse files Browse the repository at this point in the history
Only display node structure in JSONTree for arrays and empty objects
  • Loading branch information
jasongrout committed Sep 25, 2019
2 parents d427440 + 47e11f9 commit 12821a3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/json-extension/src/component.tsx
Expand Up @@ -71,6 +71,17 @@ export class Component extends React.Component<IProps, IState> {
}}
invertTheme={false}
keyPath={[root]}
getItemString={(type, data, itemType, itemString) =>
Array.isArray(data) ? (
// Always display array type and the number of items i.e. "[] 2 items".
<span>
{itemType} {itemString}
</span>
) : Object.keys(data).length === 0 ? (
// Only display object type when it's empty i.e. "{}".
<span>{itemType}</span>
) : null
}
labelRenderer={([label, type]) => {
// let className = 'cm-variable';
// if (type === 'root') {
Expand Down

0 comments on commit 12821a3

Please sign in to comment.