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

相关推荐
czhc114007566315 分钟前
722:零侵入;DBG;
c#
-银雾鸢尾-9 小时前
C#中的StringBuilder相关方法
开发语言·c#
-银雾鸢尾-10 小时前
C#中结构体与类的区别;抽象类与接口的区别
开发语言·c#
广州灵眸科技有限公司10 小时前
xfce桌面触摸校准:基于灵眸科技EASY-EAl-Orin-Nano
数据库·windows·科技
心平气和量大福大14 小时前
C#-WPF-Window主窗体
开发语言·c#·wpf
白露与泡影14 小时前
Arthas 实战指南:从方法耗时定位到 JVM 变量热修改
服务器·jvm·c#
王维同学16 小时前
[原创][Windows C++]LSA 认证、安全与通知包的注册表枚举
c++·windows·安全
YCOSA202516 小时前
雨晨 Windows 11 IOT 企业版 LTSC 24H2 轻装 2合1 26100.8968
windows·物联网
汤姆yu17 小时前
CodeGeeX 4完整安装与实操使用全指南
人工智能·windows·ai·智能体·视频模型
EIP低代码平台18 小时前
EIP低代码平台系统-字典功能讲解
低代码·c#·工作流