JSON sang C# Class

developer

Tự động tạo C# class definitions từ JSON. Hỗ trợ nullable types, JsonPropertyName attributes, nested classes và namespace.

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

How to use

  1. 1Dán JSON object vào ô nhập
  2. 2Đặt tên root class và namespace
  3. 3Chọn có dùng nullable types và JsonPropertyName attributes không
  4. 4Nhấn "Xử lý" để nhận C# class definitions sẵn dùng

Frequently Asked Questions — JSON sang C# Class

Kiểu dữ liệu C# được xác định như thế nào?+

JSON number → int / double, boolean → bool, string → string (DateTime nếu format khớp), null → object?, array → List<T>, object → class riêng.

[JsonPropertyName] attribute dùng cho gì?+

Khi JSON key là snake_case (như first_name) nhưng C# property cần PascalCase (FirstName), attribute [JsonPropertyName("first_name")] đảm bảo deserialization đúng.

Có hỗ trợ System.Text.Json không?+

Có. Tool tạo code dùng System.Text.Json (mặc định .NET 6+), không phải Newtonsoft.Json.

Related Tools