Skip to content

Conversation

muzaffarmhd
Copy link
Contributor

@muzaffarmhd muzaffarmhd commented Aug 19, 2025

PR Checklist

If you have any questions, you can refer to the Contributing Guide

What is the new behavior?

This Pull Request adds new features to the Viewer. Specifically follows the addition of Diff View with JSON Viewer.
Functionality wise the following features are added:
JSON Tree View:
a. It allows user to view payloads in expandable and collapsible form using vue-json-tree-view as the dependency to parse and view JSON as a tree. Additionally, there is a copy option added which will copy the JSON payload to the system clipboard. If the payload is Non-JSON, it is displayed as a single collapsible node.
Please check the corresponding UI:

image

Additionally, there is also a search feature implemented to search in the payload.

image

b. Visualization: We use ECharts to visualize the JSON as a tree, the depth level can be set, and on right click of node, the subtree will be copied as JSON. It also supports dark theme.
image
c. Navigation: The payload history navigation is controlled through Arrow keys, Left and Right.

Key Summary of utility function changes:

  1. New utilities added:
  • jsonTreeConverter: Converts a JSON structure to EChartsNode, the corresponding unit tests are added as well.
  1. Modified utils:
  • jsonUtils: new utility function added to stringify the ECharts subtree to JSON to avail copy functionality. Unit tests for this new utility are covered as well.

Does this PR introduce a breaking change?

  • Yes
  • No

@muzaffarmhd muzaffarmhd changed the title Feat/json tree viewer fear(viewer): add json tree viewer Aug 19, 2025
@muzaffarmhd muzaffarmhd changed the title fear(viewer): add json tree viewer feat(viewer): add json tree viewer Aug 19, 2025
@ysfscream ysfscream added feature This pr is a feature desktop MQTTX Desktop labels Aug 19, 2025
@ysfscream ysfscream moved this to In Progress in MQTTX Aug 19, 2025
@ysfscream ysfscream added this to the v1.13.0 milestone Aug 19, 2025
}
private onSearchInput(): void {
clearTimeout(this.searchTimeout)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the component doesn't clean up timeouts when destroyed?

@ysfscream
Copy link
Member

Just realized, need to test and handle Big Int issues in JSON, which is common in IoT development. Should use the existing JSON Parse method instead of JS's JSON API

@ysfscream
Copy link
Member

Wonder what kind of prompt/message and effect will appear when opening it if the payload is not JSON data?

@ysfscream
Copy link
Member

Just realized, need to test and handle Big Int issues in JSON, which is common in IoT development. Should use the existing JSON Parse method instead of JS's JSON API

Can add some edge cases/boundary conditions to the test cases for testing

return this.theme || 'light'
}
get treeOptions(): any {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's a fixed format here, the type shouldn't be any?

private searchQuery = ''
private currentIndex = 0
private copiedJson = false
private searchTimeout: any = null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private searchTimeout: any = null
private searchTimeout: number | null = null

@ysfscream
Copy link
Member

ysfscream commented Aug 20, 2025

Overall, I think there are no major issues, need to consider more edge cases, if there are performance issues should also consider them in advance, and there seem to be too many any types in the code 👀

Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop MQTTX Desktop feature This pr is a feature
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants