look at example
from pydantic import BaseModel
class A(BaseModel):
a: float = 0.0
class B(A):
b: float = 0.0
class C(A):
c: float = 0.0
b = B(a=1.1, b=2.2)
b_json = b.model_dump_json()
So I have two classes B, C which have a parent A. Here json of B instance is created and then goes somewhere in DB etc. When I take this json in some other time (from DB etc) I need to guess what class it was to correctly parse and deserialize like
B.parse_raw(b_json) # instead C.parse_raw(b_json)
Is there some good practice how to achieve this? Maybe keep some additional information? Or JSON serialization / pydantic not fit well for such purposes ?