diff --git a/ui/dockpane/DialogDockpane.xaml b/ui/dockpane/DialogDockpane.xaml
index 3b569d7..3b8967b 100644
--- a/ui/dockpane/DialogDockpane.xaml
+++ b/ui/dockpane/DialogDockpane.xaml
@@ -29,6 +29,7 @@
+
\ No newline at end of file
diff --git a/ui/dockpane/DialogDockpane.xaml.cs b/ui/dockpane/DialogDockpane.xaml.cs
index 4a594fd..0a6ce23 100644
--- a/ui/dockpane/DialogDockpane.xaml.cs
+++ b/ui/dockpane/DialogDockpane.xaml.cs
@@ -1,17 +1,8 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Text.Json;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
namespace LinkToolAddin.ui.dockpane
@@ -25,5 +16,72 @@ namespace LinkToolAddin.ui.dockpane
{
InitializeComponent();
}
+
+ private void TestButton_OnClick(object sender, RoutedEventArgs e)
+ {
+ string originalJson = @"{
+ ""name"": ""Alice"",
+ ""age"": 30,
+ ""isStudent"": false,
+ ""hobbies"": [
+ ""reading"",
+ ""swimming"",
+ ""hiking""
+ ],
+ ""address"": {
+ ""street"": ""123 Main St"",
+ ""city"": ""Anytown"",
+ ""postalCode"": ""12345""
}
-}
+}";
+
+ try
+ {
+ // 反序列化 JSON 到对象
+ Person? person = JsonSerializer.Deserialize(originalJson);
+
+ if (person != null)
+ {
+ // 序列化对象回 JSON 字符串
+ string serializedJson = JsonSerializer.Serialize(person, new JsonSerializerOptions
+ {
+ WriteIndented = true // 格式化输出
+ });
+
+ Console.WriteLine("序列化后的 JSON:");
+ Console.WriteLine(serializedJson);
+ ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(serializedJson);
+ }
+ else
+ {
+ Console.WriteLine("反序列化失败,对象为 null。");
+ }
+ }
+ catch (JsonException ex)
+ {
+ Console.WriteLine($"JSON 处理错误: {ex.Message}");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"发生错误: {ex.Message}");
+ }
+ }
+ }
+
+ // 定义数据模型类
+ public class Person
+ {
+ public string? Name { get; set; }
+ public int Age { get; set; }
+ public bool IsStudent { get; set; }
+ public List? Hobbies { get; set; }
+ public Address? Address { get; set; }
+ }
+
+ public class Address
+ {
+ public string? Street { get; set; }
+ public string? City { get; set; }
+ public string? PostalCode { get; set; }
+ }
+}
\ No newline at end of file