title: Is it possible to store nested dict in Redis as hash structure?
body: <p>I am trying to store a nested dictionary as hash with HSET, but that does not seem to be possible.</p>
  <p>An example that does <strong>not</strong> work:</p>
  <pre><code>from redis import StrictRedis
  foo = {
      &quot;host_data&quot;: {
          &quot;hostname&quot;: &quot;some_host&quot;,
          &quot;mac_address&quot;: &quot;82:fa:8e:63:40:05&quot;,
          &quot;root_password&quot;: {
              &quot;is_crypted&quot;: True,
              &quot;password&quot;: &quot;sha512_password&quot;
          },
          &quot;network&quot;: {
              &quot;ip_address&quot;: &quot;192.168.0.10/24&quot;,
              &quot;default_gateway&quot;: &quot;192.168.0.1&quot;,
              &quot;vmnic&quot;: &quot;vmnic3&quot;,
              &quot;vlan&quot;: 20
          },
          &quot;dns_servers&quot;: [
              &quot;dns01.local&quot;,
              &quot;dns02.local&quot;
          ]
      },
      &quot;installation_type&quot;: &quot;esxi&quot;,
      &quot;image_data&quot;: {
          &quot;type&quot;: &quot;vCenter_contentlib&quot;,
          &quot;host&quot;: &quot;vcenter01&quot;,
          &quot;credential&quot;: {
              &quot;username&quot;: &quot;some_user&quot;,
              &quot;password&quot;: &quot;some_password&quot;
          },
          &quot;content_library&quot;: &quot;the_content_lib_name&quot;,
          &quot;image_name&quot;: &quot;some_image&quot;
      },
      &quot;host_short_name&quot;: &quot;esxi021&quot;
  }
  
  redis_connection = StrictRedis(host='localhost', port=6379, charset=&quot;utf-8&quot;, decode_responses=True)
  redis_connection.hset(&quot;test&quot;, mapping=foo)
  </code></pre>
  <p>Throws the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/Users/project/dummy.py&quot;, line 36, in &lt;module&gt;
      redis_connection.hset(&quot;test&quot;, mapping=thing)
    File &quot;/Users/project/venv/lib/python3.9/site-packages/redis/client.py&quot;, line 3050, in hset
      return self.execute_command('HSET', name, *items)
    File &quot;/Users/project/venv/lib/python3.9/site-packages/redis/client.py&quot;, line 900, in execute_command
      conn.send_command(*args)
    File &quot;/Users/project/venv/lib/python3.9/site-packages/redis/connection.py&quot;, line 725, in send_command
      self.send_packed_command(self.pack_command(*args),
    File &quot;/Users/project/venv/lib/python3.9/site-packages/redis/connection.py&quot;, line 775, in pack_command
      for arg in imap(self.encoder.encode, args):
    File &quot;/Users/project/venv/lib/python3.9/site-packages/redis/connection.py&quot;, line 119, in encode
      raise DataError(&quot;Invalid input of type: '%s'. Convert to a &quot;
  redis.exceptions.DataError: Invalid input of type: 'dict'. Convert to a bytes, string, int or float first.
  </code></pre>
  <p>An example that <strong>works</strong>:</p>
  <pre><code>from redis import StrictRedis
  foo = {
      &quot;installation_type&quot;: &quot;esxi&quot;,
      &quot;host_short_name&quot;: &quot;esxi021&quot;
  }
  
  redis_connection = StrictRedis(host='localhost', port=6379, charset=&quot;utf-8&quot;, decode_responses=True)
  redis_connection.hset(&quot;test&quot;, mapping=foo)
  </code></pre>
  <p>In summary, my question is:</p>
  <p>Is it possible to store nested <strong>dict</strong> as hash structure in Redis?</p>
  <p><strong>NOTE:</strong> I am aware it can be stored as string and then loaded as json, but I am really trying to avoid it.</p>
  <p><strong>EDIT:</strong> Reids version is 6.2.5</p>