一款基于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

相关推荐
五_谷_丰_登4 分钟前
windows批处理脚本(bat)问题解决方案大全——持续更新
windows·bat
YCOSA202533 分钟前
迎双节 雨晨 Windows 11 IoT 企业版 LTSC 26H1 轻装 28000.2956
windows·物联网
点纭1 小时前
C 语言 第七章 常用函数(3)
c语言·开发语言·算法·oracle·c#
用户788477316342 小时前
用 .NET MAUI 一套 C# 同时出 Windows 和 Android:哪些是真能共享,哪些是 marketing
c#
csdn_aspnet2 小时前
Windows 如何隐藏 IIS Web 服务响应头中的 IIS Server 版本信息
windows·iis·url rewrite
dalong102 小时前
WPF:Modbus 状态监控
wpf·modbus
Lost of 程序猿3 小时前
用 Quartz.NET 优雅地处理 .NET 定时任务:从选型到 Docker 部署全记录
后端·c#·asp.net
AxureMost3 小时前
VideoProc Converter AI 视频转换/下载/超分辨率
windows
天若有情6734 小时前
独立开发复盘:我用 Node.js 做了个在线工具箱
前端·json·工具
李小白杂货铺4 小时前
从 macOS 免密 SSH 到 Windows 10 完整配置指南
windows·win10·openssh·踩坑·ssh服务器·免密连接·安装和配置