Skip to content

Commit

Permalink
Merge pull request #7261 from meeseeksmachine/auto-backport-of-pr-722…
Browse files Browse the repository at this point in the history
…7-on-1.x

Backport PR #7227 on branch 1.x (Only display node structure in JSONTree for arrays and empty objects)
  • Loading branch information
jasongrout committed Sep 25, 2019
2 parents 4909bb1 + c9cca7b commit ba4d87a
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 ba4d87a

Please sign in to comment.