一款基于WPF开发的BEJSON转换工具

WPF JSON转换

一款轻基于 WPF 桌面应用程序,旨在将复杂的 JSON 字符串转换为直观、可交互的树形结构。

核心特性

即时转换:一键将原始 JSON 文本转换为结构化的 TreeView。

格式校验:内置实时语法检查,确保在解析前 JSON 格式合法。

状态控制:支持全局 全部展开 和 全部折叠。

节点交互:节点可选中,便于深入查看细节数据。

功能预览

放入JSON数据,Minify进行压缩

View Tree进行树结构转换,节点处可查看子节点数量

对错误格式处进行报错

Expand All展开浏览对应节点

csharp 复制代码
private void FormatValidate_Click(object sender, RoutedEventArgs e)
        {
            string rawJson = JsonInputTextBox.Text;
            StatusTextBlock.Text = string.Empty;
            JsonTreeView.ItemsSource = null;

            if (string.IsNullOrWhiteSpace(rawJson))
            {
                StatusTextBlock.Text = "please input JSON.";
                StatusTextBlock.Foreground = Brushes.Orange;
                return;
            }

            try
            {
                JToken rootToken = JToken.Parse(rawJson);
                JsonNode rootNode = ConvertTokenToNode(rootToken);
                JsonTreeView.ItemsSource = new List<JsonNode> { rootNode };

                StatusTextBlock.Text = "JSON Correct formatting.";
                StatusTextBlock.Foreground = Brushes.Green;
            }
            catch (JsonReaderException ex)
            {
                StatusTextBlock.Text = $"Formatting error:{ex.Message} (Row: {ex.LineNumber}, Position: {ex.LinePosition})";
                StatusTextBlock.Foreground = Brushes.Red;
            }
            catch (Exception ex)
            {
                StatusTextBlock.Text = $"Unknow:{ex.Message}";
                StatusTextBlock.Foreground = Brushes.Red;
            }
        }

对应Github地址,欢迎大家关注并指正学习

https://github.com/MutoKazuo/WPF-BeJSON

相关推荐
C_心欲无痕7 小时前
ts - tsconfig.json配置讲解
linux·前端·ubuntu·typescript·json
玩泥巴的7 小时前
飞书 .NET SDK 事件处理的幂等性与去重机制
c#·.net·二次开发·飞书
在路上看风景7 小时前
3.2 FileStream
c#
zwm2698888157 小时前
6号楼 部分声光24v电压达不到,显示11v
c#
张世争8 小时前
windows clion MingW cmake 编译运行 FreeRTOS
windows·freertos·mingw·cmake·clion
AI 智能服务9 小时前
第6课__本地工具调用(文件操作)
服务器·人工智能·windows·php
IDC02_FEIYA10 小时前
SQL Server 2025数据库安装图文教程(附SQL Server2025数据库下载安装包)
数据库·windows
Kevin Wang72710 小时前
欧拉系统服务部署注意事项
网络·windows
椒颜皮皮虾11 小时前
TensorRtSharp:在 C# 世界中释放 GPU 推理的极致性能
c#·tensorrt
行止9511 小时前
WinForms 彻底隐藏 滚动条的终极解决方案
c#