JSON 转 C# 类

developer

从 JSON 自动生成 C# 类定义。支持可空类型、JsonPropertyName 属性、嵌套类和命名空间。

#json#csharp#c##.net#class#model#dotnet#developer
Loading tool...

How to use

  1. 1将 JSON 对象粘贴到输入框
  2. 2设置根类名称和命名空间
  3. 3选择是否使用 nullable 类型和 JsonPropertyName 属性
  4. 4点击"处理"获取可直接使用的 C# 类定义

Frequently Asked Questions — JSON 转 C# 类

C# 类型是如何推断的?+

JSON 数字 → int 或 double,布尔值 → bool,字符串 → string(如果格式匹配则为 DateTime),null → object?,数组 → List<T>,对象 → 独立类。

使用 System.Text.Json 还是 Newtonsoft?+

使用 System.Text.Json(.NET Core 3.0+ 内置)。在顶部添加 `using System.Text.Json.Serialization;`。

Related Tools