title: python from list of tuple create json
body: <p>I ask advice. I need to create a JSON object with the same keys. This is necessary to send a request to zabbix for host.create .
  <a href="https://www.zabbix.com/documentation/3.0/ru/manual/api/reference/host/create" rel="nofollow noreferrer">https://www.zabbix.com/documentation/3.0/ru/manual/api/reference/host/create</a> 
  If you specify more than one group, it accepts only</p>
  
  <pre><code>{"groupid": "2", "groupid": "8"}
  </code></pre>
  
  <p>Does not understand: </p>
  
  <pre><code>{"groupid": ["2","8"]}
  </code></pre>
  
  <p>I suppose to use a structure.</p>
  
  <pre><code>[("groupid","2"),("groupid","8")]
  </code></pre>
  
  <p>I solved the problem in this way, but I do not understand how to convert to JSON, because the keys are not strings</p>
  
  <pre><code>import json
  from json import JSONEncoder
  
  
  class SameKeys(JSONEncoder):
      def __init__(self, name):
          self.name = name
  
      def __repr__(self):
          return json.dumps(self.name)
  
  
  data = [("groupid", "2"), ("groupid", "8")]
  
  a = {SameKeys("groupid"): "2", SameKeys("groupid"): "8"}
  print(a)
  </code></pre>
  
  <p>But I can not understand how to do it better so as not to make crutches, there may already be a ready solution, but having spent time I did not find anything suitable. Thank you for any advice</p>