title: How to filtr json output python
body: <p>I'm new to python (just learning) and I want to extract the hostname + specify element with the last value from the zabbix database, but I'm having trouble filtering the output, I don't know how to display just one specific element. So far I have the hostname and all the elements the host contains, but I want to display one specific element, for example, system.uptime, but I don't know how to extract this one element.</p>
  <p>Second question: how can I get a nicer output? So far I have system.uptime in seconds, is it possible to somehow convert this to values - days/hours/min?
  Also, can I get the output in columns? To make the output look nicer, as below</p>
  <p>Hostname
  item.name(system.uptime): item.value</p>
  <p>Thanks for your help</p>
  <p>my code:</p>
  <pre><code>#!/usr/bin/python
  import requests
  import json
  
  ZABBIX_API_URL = &quot;http://localhost/zabbix/api_jsonrpc.php&quot;
  UNAME = &quot;Admin&quot;
  PWORD = &quot;zabbix&quot;
  
  r = requests.post(ZABBIX_API_URL,
                    json={
                        &quot;jsonrpc&quot;: &quot;2.0&quot;,
                        &quot;method&quot;: &quot;user.login&quot;,
                        &quot;params&quot;: {
                            &quot;user&quot;: UNAME,
                            &quot;password&quot;: PWORD},
                        &quot;id&quot;: 1
                    })
  
  
  AUTHTOKEN = r.json()[&quot;result&quot;]
  
  r = requests.post(ZABBIX_API_URL,
                    json={
                              &quot;jsonrpc&quot;: &quot;2.0&quot;,
                              &quot;method&quot;: &quot;host.get&quot;,
                              &quot;params&quot;: {
                                  &quot;output&quot;: [
                                      &quot;name&quot;
                                  ],
                                  &quot;selectItems&quot;: [
                                      &quot;name&quot;,
                                      &quot;lastvalue&quot;,
                                      &quot;key_&quot;
                                  ]
                                  },
                              &quot;id&quot;: 2,
                              &quot;auth&quot;: AUTHTOKEN
                          })
  
  print(json.dumps(r.json(), indent=4, sort_keys=True))
  #Logout user
  print(&quot;\nLogout user&quot;)
  r = requests.post(ZABBIX_API_URL,
                    json={
                        &quot;jsonrpc&quot;: &quot;2.0&quot;,
                        &quot;method&quot;: &quot;user.logout&quot;,
                        &quot;params&quot;: {},
  
                        &quot;id&quot;: 2,
                        &quot;auth&quot;: AUTHTOKEN
                    })
  </code></pre>
  <p>my output</p>
  <pre><code>{
                      &quot;key_&quot;: &quot;system.uptime&quot;,
                      &quot;lastvalue&quot;: &quot;7635&quot;,
                      &quot;name&quot;: &quot;System uptime&quot;
                  },
                  {
                      &quot;key_&quot;: &quot;system.users.num&quot;,
                      &quot;lastvalue&quot;: &quot;1&quot;,
                      &quot;name&quot;: &quot;Number of logged in users&quot;
                  },
                  {
                      &quot;key_&quot;: &quot;vfs.dev.queue_size[nvme0n1]&quot;,
                      &quot;lastvalue&quot;: &quot;0.002132505683045899&quot;,
                      &quot;name&quot;: &quot;nvme0n1: Disk average queue size (avgqu-sz)&quot;
                  },
                  {
                      &quot;key_&quot;: &quot;vfs.dev.read.await[nvme0n1]&quot;,
                      &quot;lastvalue&quot;: &quot;0&quot;,
                      &quot;name&quot;: &quot;nvme0n1: Disk read request avg waiting time (r_await)&quot;
                  },
                  {
                      &quot;key_&quot;: &quot;vfs.dev.read.rate[nvme0n1]&quot;,
                      &quot;lastvalue&quot;: &quot;0&quot;,
                      &quot;name&quot;: &quot;nvme0n1: Disk read rate&quot;
                  },
                  {
                      &quot;key_&quot;: &quot;vfs.dev.read.time.rate[nvme0n1]&quot;,
                      &quot;lastvalue&quot;: &quot;0&quot;,
                      &quot;name&quot;: &quot;nvme0n1: Disk read time (rate)&quot;
                  },
                  {
                      &quot;key_&quot;: &quot;vfs.dev.util[nvme0n1]&quot;,
                      &quot;lastvalue&quot;: &quot;0.6532914235362834&quot;,
                      &quot;name&quot;: &quot;nvme0n1: Disk utilization&quot;
                  },
                  {
                      &quot;key_&quot;: &quot;vfs.dev.write.await[nvme0n1]&quot;,
                      &quot;lastvalue&quot;: &quot;0.1358211148456916&quot;,
                      &quot;name&quot;: &quot;nvme0n1: Disk write request avg waiting time (w_await)&quot;
                  },
  </code></pre>