title: Json serialization of nested dataclasses
body: <p>I would need to take the question about <code>json serialization of @dataclass</code> from <a href="https://stackoverflow.com/questions/51286748/make-the-python-json-encoder-support-pythons-new-dataclasses">Make the Python json encoder support Python&#39;s new dataclasses</a>  a bit further: consider when they are in a nested structure. </p>
  
  <p>Consider:</p>
  
  <pre><code>import json
  from attr import dataclass
  from dataclasses_json import dataclass_json
  @dataclass
  @dataclass_json
  class Prod:
      id: int
      name: str
      price: float
  
  prods = [Prod(1,'A',25.3),Prod(2,'B',79.95)]
  pjson = json.dumps(prods)
  </code></pre>
  
  <p>That gives us:</p>
  
  <pre><code>TypeError: Object of type Prod is not JSON serializable
  </code></pre>
  
  <p>Note the above does incorporate one of the answers <a href="https://stackoverflow.com/a/59688140/1056563">https://stackoverflow.com/a/59688140/1056563</a> . It  claims to support the nested case via the <code>dataclass_json</code> decorator . Apparently that does not actually work. </p>
  
  <p>I also tried another of the answers <a href="https://stackoverflow.com/a/51286749/1056563">https://stackoverflow.com/a/51286749/1056563</a> :</p>
  
  <pre><code>class EnhancedJSONEncoder(json.JSONEncoder):
          def default(s, o):
              if dataclasses.is_dataclass(o):
                  return dataclasses.asdict(o)
              return super().default(o)
  </code></pre>
  
  <p>And I created a helper method for it:</p>
  
  <pre><code>def jdump(s,foo):
      return json.dumps(foo, cls=s.c.EnhancedJSONEncoder)
  </code></pre>
  
  <p>But using that method also did not effect the (error) result.  Any further tips?</p>