public class Root
{
public long Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public IEnumerable<string> Roles { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string Street { get; set; }
public string City { get; set; }
}
Extension Settings
Setting
Default
Description
json2csharp.alwaysUseRootClassName
false
Skip the prompt and always use the default root class name
json2csharp.rootClassName
"Root"
Default root class name
json2csharp.typeStyle
"class"
Type style: class, recordPositional, or recordProperties
Nullable handling: none, nullable (?), or defaultValues
json2csharp.inferEnums
false
Attempt to infer enum types from JSON values
json2csharp.inferDateTimes
true
Attempt to infer DateTime types from strings
json2csharp.namespaceMode
"withoutNamespace"
Namespace inclusion: withoutNamespace (single menu, no namespace), withNamespace (single menu, always namespace), or choose (submenu with both options)
json2csharp.serializationAttributes
"SystemTextJson"
Serialization attributes: none, SystemTextJson, or NewtonsoftJson
json2csharp.attributeRendering
"whenDifferent"
When to render attributes: whenDifferent or always. Only applies when serializationAttributes is SystemTextJson or NewtonsoftJson
Requirements
VS Code 1.96.0 or later
Known Issues
Complex union types may not convert perfectly
Very large JSON files may take a moment to process