JSON in C#

Genera classi o record C# da JSON con Newtonsoft o System.Text.Json.

Generatore di classi online gratuito da JSON a C#

Incolla JSON e ottieni le definizioni delle classi C# con tipi dedotti, classi nidificate e List<T> per le matrici. Scegli classi POCO o record C# 9+, nomi di proprietà PascalCase e attributi di serializzazione Newtonsoft.Json o System.Text.Json.

Imposta un nome di classe radice e uno spazio dei nomi facoltativo, quindi copia il codice generato nel tuo progetto .NET. Tutte le conversioni vengono eseguite nel tuo browser: non viene caricato nulla.

Frequently Asked Questions

What is the difference between POCO and record?
POCO (Plain Old CLR Object) classes are mutable reference types with get/set properties - the traditional C# approach. Records (C# 9+) are immutable by default with value-based equality. Use records for DTOs and API models; POCOs when you need mutable objects.
Which JSON library attributes are supported?
Dokall supports Newtonsoft.Json (JsonProperty attributes) and System.Text.Json (JsonPropertyName attributes). Choose based on your project's JSON serializer. System.Text.Json is the modern default in .NET Core 3+.
How are C# property names generated?
Property names use PascalCase by default, following C# conventions. JSON camelCase keys are converted: firstName becomes FirstName. You can set a namespace and root class name before generating.
How are arrays and nested objects handled?
JSON arrays become List<T> with the element type inferred. Nested objects become separate nested classes. Deep nesting produces nested class definitions within the root class.
Can I use this for Entity Framework models?
The generated classes work as DTOs and API models. Entity Framework entities typically need additional attributes (Key, Required, navigation properties) that are not inferred from JSON. Use the output as a starting point and add EF-specific annotations manually.