I'm doing a project to learn more about working with Python dataclasses
. Specifically, I'm trying to represent an API response as a dataclass
object. However, I'm running into an issue due to how the API response is structured.
Here is an example response from the API:
{
"@identifier": "example",
"@name": "John Doe",
}
Some of the fields have special characters in their names. This means I cannot map the attributes of my dataclass
directly, since special characters such as @
are not allowed in property names (SyntaxError
).
Is there a way to define an alias for my dataclass
properties, such that I can map the API response directly to the dataclass
object? Or is it necessary to clean the response first?