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

Feature request: JSON viewer/editor element #3988

Open
barseghyanartur opened this issue Mar 5, 2025 · 4 comments
Open

Feature request: JSON viewer/editor element #3988

barseghyanartur opened this issue Mar 5, 2025 · 4 comments
Labels
enhancement New feature or request good first issue (typescript) Good first issue on the frontend/typescript good first issue Good for newcomers help wanted Extra attention is needed

Comments

@barseghyanartur
Copy link

Description

Given a valid JSON, the JSON viewer/editor element renders it nicely (highlighting keys, breaking long lines, copy raw functionality, etc).

Suggested solution

None.

Alternative

No response

Additional context

No response

@barseghyanartur barseghyanartur added the enhancement New feature or request label Mar 5, 2025
@mscolnick
Copy link
Contributor

For editing, you can use mo.ui.code_editor(json_string, language='json'). This gives you a code editor with key's highlighted and collapsible.

For just viewing, you can return a dictionary in the last element of the cell, or use mo.tree(dictionary)

Here the examples on our playground

@barseghyanartur
Copy link
Author

Wow! Amazing. The mo.tree is exactly what I needed. Thanks so much!

@barseghyanartur
Copy link
Author

@mscolnick:

I thoroughly tested the tree component and I admit it's a wonderful tool. I've tried the code editor with both json and javascript options. The tree component comes very close to what I want, but still it's not a JSON tree. For instance, when you copy it, you get a Python dict, not a JSON. I believe JSON viewer component would be a good addition to the existing components list.

@mscolnick
Copy link
Contributor

We can add mo.json() as well which will look similar but the copy and rendering will be json instead of python values

@mscolnick mscolnick added good first issue Good for newcomers help wanted Extra attention is needed good first issue (typescript) Good first issue on the frontend/typescript labels Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue (typescript) Good first issue on the frontend/typescript good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants