ProductDto
System.Text.Json serialization attributes to control wire format. Definition
Section titled Definitionpublic class ProductDtoRemarks
Section titled RemarksSystem.Text.Json:JsonPropertyNameAttributeto map CLR property names to snake_case or camelCase JSON keys.JsonIgnoreAttributeto hide internal-only properties from serialized output.JsonRequiredAttributeto enforce that a property must be present during deserialization.
JsonRequiredAttribute will cause JsonSerializer to throw a JsonException if the corresponding key is missing from the input JSON.Properties10
Section titled PropertiesAddedAt Section titled AddedAt DateTimeOffset DateTimeOffset ProductDto.AddedAtGets or sets the UTC date and time when the product was first added to the catalogue. Maps to the JSON key "added_at".
string? string? ProductDto.CategoryGets or sets the product category used for catalogue organization. Maps to the JSON key "category".
string? string? ProductDto.DescriptionGets or sets the long-form product description, supporting plain text only. Maps to the JSON key "description".
Remarks
null, the product has no description and UIs should display a placeholder or omit the section entirely.Guid Guid ProductDto.IdGets or sets the unique product identifier. This is required during deserialization and maps to the JSON key "id".
string? string? ProductDto.InternalTrackingCodeAn internal tracking code used by the warehouse management system. This property is excluded from JSON serialization via JsonIgnoreAttribute and is never exposed through the API.
IsAvailable Section titled IsAvailable bool bool ProductDto.IsAvailableGets or sets whether the product is currently available for purchase. Maps to the JSON key "available".
Remarks
false, the product should not appear in storefront listings but may still be visible in the admin catalogue.Name Section titled Name string string ProductDto.NameGets or sets the human-readable product name displayed in catalogues and search results. Maps to the JSON key "name".
Price Section titled Price decimal decimal ProductDto.PriceGets or sets the unit price in the store's base currency. Maps to the JSON key "price".
Remarks
Decimal to preserve precision in financial calculations. Negative values are not permitted.string? string? ProductDto.SkuGets or sets the stock keeping unit code for inventory tracking. Maps to the JSON key "sku".
Remarks
XX-#### where XX is a two-letter category prefix and #### is a numeric sequence.Tags Section titled Tags List<string> List<string> ProductDto.TagsGets or sets the list of searchable tags associated with this product. Maps to the JSON key "tags".
Remarks
Examples
Section titled ExamplesSerializing a product to JSON:
var product = new ProductDto{ Id = Guid.NewGuid(), Name = "Wireless Mouse", Description = "Ergonomic wireless mouse with USB-C receiver", Price = 29.99m, Sku = "WM-1001", Category = "Peripherals", Tags = ["wireless", "ergonomic", "usb-c"], IsAvailable = true};
string json = JsonSerializer.Serialize(product);// {"id":"...","name":"Wireless Mouse","description":"...","price":29.99,...}Deserializing from JSON (required properties enforced):
string json = """ { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "name": "Keyboard", "price": 59.99 } """;var product = JsonSerializer.Deserialize<ProductDto>(json);