title: Make the Python json encoder support Python's new dataclasses
body: <p>Starting with Python 3.7, there is something called a dataclass:</p>
  
  <pre><code>from dataclasses import dataclass
  
  @dataclass
  class Foo:
      x: str
  </code></pre>
  
  <p>However, the following fails:</p>
  
  <pre><code>&gt;&gt;&gt; import json
  &gt;&gt;&gt; foo = Foo(x="bar")
  &gt;&gt;&gt; json.dumps(foo)
  TypeError: Object of type Foo is not JSON serializable
  </code></pre>
  
  <p>How can I make <code>json.dumps()</code> encode instances of <code>Foo</code> into json <a href="https://www.json.org/" rel="noreferrer"><em>objects</em></a>?</p>