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

相关推荐
雨落倾城夏未凉3 天前
第四章c#方法-参数数组和可选参数(16)
后端·c#
唐青枫4 天前
线程不是越多越快:C#.NET Thread 生命周期、同步与后台工作线程实战
c#·.net
唐青枫5 天前
别只会反射:C#.NET Emit 动态生成代码实战详解
c#·.net
咕白m6255 天前
.NET 环境下 Word 超链接批量提取方案
c#·.net
用户91721561902115 天前
C# 通信协议增量解析:用状态机处理半包和粘包
c#
小码编匠6 天前
C# 工控上位机必备:数据转换工具类与十个核心模块
后端·c#·.net
疯狂SQL6 天前
手写高性能在线 JSON 工具|Web Worker 工程化打包 + 语法自动修复 + 多语言代码生成实战
typescript·json·next.js·web worker·前端性能优化·esbuild·源码实战
唐青枫8 天前
别再乱用 StartNew:C#.NET TaskFactory 任务调度实战详解
c#·.net
Artech8 天前
[MAF预定义的AIContextProvider-03]ChatHistoryMemoryProvider——赋予Agent从经验中学习的能力
ai·c#·agent·memory·maf
Scout-leaf10 天前
C#摸鱼实录——IoC与DI案例详解
c#