title: Initializing a pydantic dataclass from json
body: <p>I'm in the process of converting existing <code>dataclasses</code> in my project to <code>pydantic-dataclasses</code>, I'm using these <code>dataclasses</code> to represent models I need to both encode-to and parse-from json.</p>
  <p>Here's an example of my current approach that is not good enough for my use case, I have a class <code>A</code> that I want to both convert into a dict (to later be converted written as json) and to read from that dict.
  But the only way I can find to parse the json back into a model gives me back the underlying <code>BaseModel</code> and not the <code>dataclass</code>.</p>
  <p>note that I'm using the <code>asdict</code> function to convert the <code>dataclass</code> to a <code>dict</code> as it's what the <code>pydantic_encoder</code> uses to convert the <code>dataclass</code> to json, and using the <code>pydantic_encoder</code> what the documentation recommends to convert a <code>pydantic-dataclass</code> to json:
  <a href="https://pydantic-docs.helpmanual.io/usage/dataclasses/" rel="noreferrer">https://pydantic-docs.helpmanual.io/usage/dataclasses/</a></p>
  <pre class="lang-py prettyprint-override"><code>from dataclasses import asdict
  from pydantic.dataclasses import dataclass
  from pydantic import BaseModel
  
  @dataclass
  class A:
      x: str
  
  a = A(&quot;string&quot;)
  a_dict = asdict(a)
  parsed_a = A.__pydantic_model__.parse_obj(a_dict)
  
  print(f&quot;type of a: {type(a)}&quot;)
  print(f&quot;type of parsed_a: {type(parsed_a)}&quot;)
  
  print(f&quot;a is instance of A: {isinstance(a, A)}&quot;)
  print(f&quot;parsed_a is instance of A: {isinstance(parsed_a, A)}&quot;)
  
  print(f&quot;a is instance of BaseModel: {isinstance(a, BaseModel)}&quot;)
  print(f&quot;parsed_a is instance of BaseModel: {isinstance(parsed_a, BaseModel)}&quot;)
  </code></pre>
  <p>output:</p>
  <pre><code>type of a: &lt;class '__main__.A'&gt;
  type of parsed_a: &lt;class '__main__.A'&gt;
  a is instance of A: True
  parsed_a is instance of A: False
  a is instance of BaseModel: False
  parsed_a is instance of BaseModel: True
  </code></pre>
  <p>Is there maybe a way to initialize <code>A</code> from the parsed <code>BaseModel</code>?</p>