Python JSON

This topic is to discuss the following lesson:

Hi rene.

In a json like this…

{
    "routers": 
      {
        "name": "CSR1000V",
        "vendor": "Cisco",
        "type": "virtual"
      },
      {
        "name": "1921",
        "vendor": "Cisco",
        "type": "hardware"
      }
   
}

How can I select the “routers” label?

In this json I have not the “[]” after “routers” labels.

For example I have to select…if is there routers do something…if there a firewalls do something other…

Thanks you

Hi Giovanni,

You probably already have an answer but just in case…

When you want to “select” a certain field in a JSON (or dictionary), it’s best to use an IDE like vscode and use the debugger to select what you need. For example:

Rene