title: How can I fix this problem serializing JSON?
body: <p>I want to post input data with python to a JSON document database. But this error appears. I think it's a problem of serializing but don't think how to fix it:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;C:\Users\33769\AppData\Local\Programs\Python\Python310\lib\json\__init__.py&quot;, line 231, in dumps
      return _default_encoder.encode(obj)
    File &quot;C:\Users\33769\AppData\Local\Programs\Python\Python310\lib\json\encoder.py&quot;, line 199, in encode
      chunks = self.iterencode(o, _one_shot=True)
    File &quot;C:\Users\33769\AppData\Local\Programs\Python\Python310\lib\json\encoder.py&quot;, line 257, in iterencode
      return _iterencode(o, 0)
    File &quot;C:\Users\33769\AppData\Local\Programs\Python\Python310\lib\json\encoder.py&quot;, line 179, in default
      raise TypeError(f'Object of type {o.__class__.__name__} '
  TypeError: Object of type set is not JSON serializable
  &gt;&gt;&gt; res  = requests.post(url, headers=headers, data=data)
  &gt;&gt;&gt; print(res.text)
  {&quot;error&quot;:&quot;bad_request&quot;,&quot;reason&quot;:&quot;invalid UTF-8 JSON&quot;}
  </code></pre>
  <p>Here is the code I used:</p>
  <pre><code>&gt;&gt;&gt; import requests
  &gt;&gt;&gt; import json
  &gt;&gt;&gt; url = 'http://admin:pass@localhost:5984/db_reviewin'
  &gt;&gt;&gt; data = {'key':'value'}
  &gt;&gt;&gt; headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
  &gt;&gt;&gt; a = input(&quot;ton_nom:&quot;)
  ton_nom:ayoub
  &gt;&gt;&gt; b = input(&quot;ton_age&quot;)
  ton_age16
  &gt;&gt;&gt; c = input(&quot;gender:&quot;)
  gender:M
  &gt;&gt;&gt; e_mail = input(&quot;ton e_mail:&quot;)
  ton e_mail:ayoub_semsar@yahoo.com
  &gt;&gt;&gt; d  = input(&quot;country:&quot;)
  country:france
  &gt;&gt;&gt; data = {&quot;full_name&quot;:{a}, &quot;age&quot;:{b}, &quot;gender&quot;:{c}, &quot;e_mail&quot;:{e_mail}, &quot;country&quot;:{d}}
  &gt;&gt;&gt; res  = requests.post(url, headers=headers, data=json.dumps(data))
  </code></pre>