FormatSerSchema
This class defines a schema for formatting serialization using a typed dictionary. It requires a specific type identifier and a formatting string, while allowing for an optional specification of when the formatting should be applied.
Attributes
| Attribute | Type | Description |
|---|---|---|
| type | Literal['format'] | Discriminator value used to identify the serialization schema as a string formatting type. |
| formatting_string | str | The Python format string used to define how the object should be converted into a string representation. |
| when_used | WhenUsed = json-unless-none | Determines the specific conditions under which this serialization format is applied, defaulting to 'json-unless-none'. |
Methods
type()
def type() - > Literal['format']
Specifies the schema type identifier, which must be set to the literal string 'format' to indicate a formatting-based serialization strategy.
Returns
| Type | Description |
|---|---|
Literal['format'] | The fixed literal string 'format' used for schema identification. |
formatting_string()
def formatting_string() - > str
Defines the Python-style format string used to transform the input value into a formatted string representation.
Returns
| Type | Description |
|---|---|
str | The template string containing placeholders for value formatting. |
when_used()
def when_used() - > WhenUsed
Determines the conditions under which this formatting schema is applied during serialization, defaulting to 'json-unless-none'.
Returns
| Type | Description |
|---|---|
WhenUsed | A configuration value controlling the serialization context and null-handling behavior. |