You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`msgspec.inspect.type_info` is one way, but it's a bit overkill for this use case. And `__struct_encode_fields__` is technically non-public (and may be removed in the future). The best way to get this information is to use `msgspec.struct.fields` ([docs](https://jcristharif.com/msgspec/api.html#msgspec.structs.fields)). You're looking for the `encode_name` attribute on `FieldInfo` in the result:
In [3]: classExample(msgspec.Struct):
...: user_id: int=msgspec.field(name="userId")
...:
In [4]: msgspec.structs.fields(Example)
Out[4]: (FieldInfo(name='user_id', encode_name='userId', type=<class'int'>, default=NODEFAULT, default_factory=NODEFAULT),)
Originally posted by @jcrist in jcrist/msgspec#672 (comment)
The text was updated successfully, but these errors were encountered: