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

Only display node structure in JSONTree for arrays and empty objects #7227

Merged
merged 3 commits into from Sep 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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