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
Conversation
The item strings draw the attention of the user away from the actual content of the tree.
Thanks for making a pull request to JupyterLab! To try out this branch on binder, follow this link: |
In the screenshot, it seems |
What does it show after this change for non-empty arrays and for empty objects?
|
It was already blank before but the We could display the |
I'd lean towards leaving in the count of array items. It's certainly much more useful information than the object key count in most circumstances. But either way is fine |
+1. That looks a lot better
I would also lean towards having the array count displayed, but I also agree it's not a huge deal to me right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Some checks failed but it doesn't seem related to this PR's changes. Is there something I can do to help get this merged? |
For others wanting to test this, here is the code above for convenience: from dataclasses import dataclass
@dataclass
class Tree:
data: dict
def _repr_json_(self):
return self.data, {"expanded": True} Tree({"emptyobject": {}, "emptyarray": [], "fullarray": [1,2,3,4,5], "nested array": [{}, {"a": 1, "b": 2}, []]}) |
@meeseeksdev backport to 1.x |
…for arrays and empty objects
…7-on-1.x Backport PR #7227 on branch 1.x (Only display node structure in JSONTree for arrays and empty objects)
I feel like the item strings draw the attention away from the actual content of the tree.
Code changes
Pass an additional
getItemString
prop to<JSONTree />
.User-facing changes
In a notebook
Before
After
Exploring a JSON file
Before
After
If you feel this is too much, we could do like Google Chrome DevTools console which only shows this information for arrays (not for objects):
Backwards-incompatible changes
None.