0

I'm beginner in programming and really need your help with problem in Python.

I have python script like this:

import requests
import json

response = requests.get('http://192.168.1.194/status/relay/')
print(json.dumps(response.json(), indent = 4))

Which generate in cmd list like this

{
    "wifi_sta": {
        "connected": true,
        "ssid": "Network 3",
        "ip": "192.168.1.194",
        "rssi": -60
    },
    "cloud": {
        "enabled": true,
        "connected": false
    }

I'm fighting since yesterday to reduced response to one information - to status in row "enabled" : true How I have to change code to get only word "true" from key "cloud" subkey "enabled" ?

I know how to get key cloud with two subkeys but I don't have any idea how to get value from subkey "enabled".

Thank you for answers..

  • 1
    `variable['cloud']['enabled']` – Barmar Jan 05 '21 at 22:14
  • What makes you think nested keys are any different from top-level keys? – Barmar Jan 05 '21 at 22:14
  • I can't solve problem whit this link on the top. When I type command response.json().get('cloud') I get list like this {'enabled': False, 'connected': False}. I tried with variable['cloud']['enable'] but I don't know where I have to put it, I got errors – elektryx Jan 06 '21 at 09:01

0 Answers0