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

相关推荐
tealcwu23 分钟前
【Unity实战】Unity IAP 5.3 中实现 Windows Custom Store 实战教程
windows·unity·游戏引擎
yumgpkpm1 小时前
华为HUAWEI昇腾910B下千问Qwen3.6-27B在的推理加速实践
sql·华为·langchain·json·ai编程·ai写作·gpu算力
闪电悠米1 小时前
黑马点评-分布式锁-02_simple_redis_lock_setnx
java·数据库·spring boot·redis·分布式·缓存·wpf
unityのkiven1 小时前
工作分享1(26.5.27):基于栈实现全局返回逻辑通用架构设计(适配异步 + 确认弹窗)
游戏·unity·c#·客户端架构
ZenosDoron1 小时前
vsnprintf可变参数格式化输出函数
windows
z落落2 小时前
C# 多态 + 函数重载(静态多态)+运算符重载
开发语言·c#
闪电悠米2 小时前
黑马点评-分布式锁-03_lua_atomic_unlock
java·数据库·分布式·缓存·oracle·wpf·lua
许彰午2 小时前
11_Java集合框架概述
java·windows·python
Fms_Sa2 小时前
分治法—最大子段问题
算法·c#
rick9772 小时前
C# 动态对象实战:用 DynamicObject 打造你的"万能插件架构"
c#